Add tmux, vim and nvim config

This commit is contained in:
Jan Eitzinger 2023-02-11 14:11:00 +01:00
parent 600afe5914
commit c53bd1583e
9 changed files with 1144 additions and 0 deletions

View File

@ -0,0 +1,103 @@
local ok, lsp = pcall(require, 'lsp-zero')
if not ok then
return
end
lsp.preset("recommended")
-- Fix Undefined global 'vim'
lsp.configure('sumneko_lua', {
settings = {
Lua = {
diagnostics = {
globals = { 'vim' }
}
}
}
})
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local luasnip = require("luasnip")
local cmp = require('cmp')
local cmp_select = {behavior = cmp.SelectBehavior.Select}
local cmp_mappings = lsp.defaults.cmp_mappings({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<CR>'] = cmp.mapping.confirm({ select = true }),
["<C-e>"] = cmp.mapping.abort(),
["<C-Space>"] = cmp.mapping.complete(),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
})
local lspkind = require('lspkind')
local cmp_formatting = {
format = lspkind.cmp_format({
mode = 'symbol_text', -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
})
}
lsp.setup_nvim_cmp({
mapping = cmp_mappings,
formatting = cmp_formatting
})
lsp.on_attach(function(client, bufnr)
local bufmap = function(mode, lhs, rhs)
local opts = {buffer = true, remap = false}
vim.keymap.set(mode, lhs, rhs, opts)
end
-- List diagnostics in Telescope
bufmap('n', 'gA', '<cmd>Telescope diagnostics<cr>')
-- Lists all the references
bufmap('n', 'gr', '<cmd>Telescope lsp_references<cr>')
end)
local on_attach_format = function(client)
require("lsp-format").on_attach(client)
end
lsp.configure('clangd', {
on_attach = on_attach_format
})
lsp.nvim_workspace()
lsp.setup()
vim.diagnostic.config({
virtual_text = false,
severity_sort = true,
float = {
border = 'rounded',
source = 'always',
header = '',
prefix = '',
},
})

View File

@ -0,0 +1,76 @@
local ok, telekasten = pcall(require, 'telekasten')
local home = vim.fn.expand("~/doc/zettelkasten")
telekasten.setup {
home = home,
take_over_my_home = true,
auto_set_filetype = true,
dailies = home .. '/' .. 'daily',
weeklies = home .. '/' .. 'weekly',
templates = home .. '/' .. 'templates',
image_subdir = "img",
extension = ".md",
new_note_filename = "uuid-title",
uuid_type = "%Y%m%d%H%M",
uuid_sep = "-",
follow_creates_nonexisting = true,
dailies_create_nonexisting = true,
weeklies_create_nonexisting = true,
journal_auto_open = false,
-- template for new notes (new_note, follow_link)
-- set to `nil` or do not specify if you do not want a template
template_new_note = home .. '/' .. 'templates/new_note.md',
-- template for newly created daily notes (goto_today)
-- set to `nil` or do not specify if you do not want a template
template_new_daily = home .. '/' .. 'templates/daily.md',
-- template for newly created weekly notes (goto_thisweek)
-- set to `nil` or do not specify if you do not want a template
template_new_weekly= home .. '/' .. 'templates/weekly.md',
-- image link style
-- wiki: ![[image name]]
-- markdown: ![](image_subdir/xxxxx.png)
image_link_style = "wiki",
-- default sort option: 'filename', 'modified'
sort = "filename",
-- integrate with calendar-vim
plug_into_calendar = true,
calendar_opts = {
weeknm = 4,
calendar_monday = 1,
calendar_mark = 'left-fit',
},
close_after_yanking = false,
insert_after_inserting = true,
tag_notation = "#tag",
command_palette_theme = "dropdown",
show_tags_theme = "ivy",
subdirs_in_links = true,
template_handling = "smart",
new_note_location = "smart",
rename_update_links = true,
follow_url_fallback = nil,
}
local map = vim.keymap.set
map('n',"<leader>zf", "<cmd>Telekasten find_notes<cr>")
map('n',"<leader>zd", "<cmd>Telekasten find_daily_notes<cr>")
map('n',"<leader>zg", "<cmd>Telekasten search_notes<cr>")
map('n',"<leader>zz", "<cmd>Telekasten follow_link<cr>")
map('n',"<leader>zn", "<cmd>Telekasten new_note<cr>")
map('n',"<leader>zr", "<cmd>Telekasten rename_note<cr>")
map('n',"<leader>zc", "<cmd>Telekasten show_calendar<cr>")
map('n',"<leader>#", "<cmd>Telekasten show_tags<cr>")
map('n',"<leader>z", "<cmd>Telekasten panel<cr>")
vim.api.nvim_set_hl(0, "tklink", { fg = "#689d6a", bg = "" })
vim.api.nvim_set_hl(0, "tkBrackets", { fg = "gray", bg = "gray" })

View File

@ -0,0 +1,34 @@
local ok, telescope = pcall(require, 'telescope')
if not ok then
return
end
telescope.setup {
defaults = {
prompt_prefix = ' ',
selection_caret = ' ',
layout_config = { horizontal = { preview_width = 0.5 } },
file_ignore_patterns = { 'node_modules/.*' },
},
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
}
}
}
telescope.load_extension('fzf')
telescope.load_extension('file_browser')
local map = vim.keymap.set
map('n',"<C-n>", "<cmd>Telescope file_browser<cr>")
map('n',"<C-t>", "<cmd>Telescope current_buffer_tags<cr>")
map('n',"<leader>e", "<cmd>Telescope find_files<cr>")
map('n',"<leader>f", "<cmd>Telescope live_grep<cr>")
map('n',"<leader>g", "<cmd>Telescope grep_string<cr>")
map('n',"<leader>b", "<cmd>Telescope buffers<cr>")
map('n',"<leader>h", "<cmd>Telescope help_tags<cr>")

View File

@ -0,0 +1,28 @@
local ok, treesitter = pcall(require, 'nvim-treesitter.configs')
if not ok then
return
end
treesitter.setup {
-- A list of parser names, or "all"
ensure_installed = "all",
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
highlight = {
-- `false` will disable the whole extension
enable = true,
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false,
},
}

257
dot_config/nvim/init.lua Normal file
View File

@ -0,0 +1,257 @@
HOME = os.getenv("HOME")
vim.cmd([[colorscheme gruvbox]])
vim.g.mapleader = " "
vim.g.maplocalleader = '\\'
-- Plugins
require "paq" {
"savq/paq-nvim";
{"nvim-treesitter/nvim-treesitter", run=function() vim.cmd "TSUpdate" end};
"nvim-treesitter/nvim-treesitter-textobjects";
"nvim-tree/nvim-web-devicons";
"onsails/lspkind.nvim";
"VonHeikemen/lsp-zero.nvim";
-- LSP support
"lukas-reineke/lsp-format.nvim";
"neovim/nvim-lspconfig";
"williamboman/mason.nvim";
"williamboman/mason-lspconfig.nvim";
-- Autocomplete
"hrsh7th/nvim-cmp";
"hrsh7th/cmp-buffer";
"hrsh7th/cmp-path";
"saadparwaiz1/cmp_luasnip";
"hrsh7th/cmp-nvim-lsp";
"hrsh7th/cmp-nvim-lua";
-- Snippets
"L3MON4D3/LuaSnip";
"rafamadriz/friendly-snippets";
"kylechui/nvim-surround";
"windwp/nvim-autopairs";
"numToStr/Comment.nvim";
{"phaazon/hop.nvim", branch="v2"};
"nvim-lua/plenary.nvim";
-- Fuzzy search
{"nvim-telescope/telescope-fzf-native.nvim", run="gmake"};
"nvim-telescope/telescope-file-browser.nvim";
"nvim-telescope/telescope.nvim";
"mfussenegger/nvim-dap";
"rcarriga/nvim-dap-ui";
"lewis6991/gitsigns.nvim";
-- "ray-x/go.nvim";
"renerocksai/telekasten.nvim";
"renerocksai/calendar-vim";
"nvim-lualine/lualine.nvim";
"ellisonleao/gruvbox.nvim";
}
require('nvim-web-devicons').setup {}
require('lsp-format').setup {}
require('nvim-autopairs').setup()
require('nvim-surround').setup()
require('Comment').setup()
require('hop').setup()
require('dapui').setup()
require('gitsigns').setup()
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'gruvbox',
component_separators = '|',
section_separators = '',
}
}
require("gruvbox").setup {
italic = false,
contrast = "hard"
}
local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function()
require('go.format').goimport()
end,
group = format_sync_grp,
})
-- Options
local o = vim.opt
-- basic settings
o.encoding = "utf-8"
o.backspace = "indent,eol,start" -- backspace works on every char in insert mode
o.completeopt = 'menu,menuone,noselect'
o.history = 1000
o.dictionary = '/usr/share/dict/words'
o.startofline = true
o.title = true
o.clipboard='unnamedplus'
-- Mapping waiting time
o.timeoutlen = 200
o.ttimeoutlen = 0
-- Spellchecker
o.spelllang="en_us"
o.spellfile= HOME .. '/.vim/spell/en.utf8.add'
o.thesaurus= HOME .. '/.vim/thesaurus/english.txt'
-- Display
o.showmatch = true -- show matching brackets
o.colorcolumn = '90'
o.cursorline = true
o.scrolloff = 8 -- always show 3 rows from edge of the screen
o.splitbelow = true
o.splitright = true
o.virtualedit = 'block'
o.synmaxcol = 300 -- stop syntax highlight after x lines for performance
o.laststatus = 2 -- always show status line
o.list = false -- do not display white characters
o.termguicolors = true
o.background = "dark"
-- o.updatetime = 100
vim.cmd([[highlight SpellBad cterm=undercurl ctermfg=Red]])
-- Folding
o.foldenable = false
o.foldlevel = 4 -- limit folding to 4 levels
o.foldmethod = 'syntax' -- use language syntax to generate folds
o.wrap = false --do not wrap lines even if very long
o.eol = false -- show if there's no eol char
o.showbreak= '' -- character to show when line is broken
-- Sidebar
o.number = true -- line number on the left
o.relativenumber = true
o.numberwidth = 3 -- always reserve 3 spaces for line number
o.signcolumn = 'yes' -- keep 1 column for coc.vim check
o.modelines = 0
-- Bottombar
o.showcmd = true -- display command in bottom bar
o.ruler = false
o.showmode = false
-- Search
o.incsearch = true -- starts searching as soon as typing, without enter needed
o.hlsearch = true -- highlighting of search matches
o.ignorecase = true -- ignore letter case when searching
o.smartcase = true -- case insentive unless capitals used in search
o.wildignorecase = true
o.matchtime = 2 -- delay before showing matching paren
o.mps = vim.o.mps .. ",<:>"
-- White characters
o.smartindent = true
o.breakindent = true
o.tabstop = 4
o.shiftwidth = 4 -- indentation rule
o.softtabstop = 4
o.expandtab = true -- expand tab to spaces
o.smarttab = true
-- Shortmess
o.shortmess = o.shortmess
+ {
A = true, -- don't give the "ATTENTION" message when an existing swap file is found.
I = true, -- don't give the intro message when starting Vim |:intro|.
W = true, -- don't give "written" or "[w]" when writing a file
c = true, -- don't give |ins-completion-menu| messages
m = true, -- use "[+]" instead of "[Modified]"
}
-- Format options
o.formatoptions = o.formatoptions
+ {
c = false,
o = false, -- O and o, don't continue comments
r = true, -- Pressing Enter will continue comments
}
-- Backup files
o.hidden = true
o.autowrite = true
o.autoread = true
o.backup = true -- use backup files
o.writebackup = false
o.swapfile = false -- do not use swap file
o.undofile = true
o.undodir = HOME .. '/.vim/dirs/undo//' -- undo files
o.backupdir = HOME .. '/.vim/dirs/backup//' -- backups
-- Commands mode
o.wildmenu = true -- on TAB, complete options for system command
o.wildignore = 'deps,.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,.DS_Store,*.aux,*.out,*.toc'
-- Mappings {{{
local map = vim.keymap.set
map({'n','v'}, '<Space>', "<Nop>", { silent = true })
-- clear the search buffer when hitting return
map('n', '<CR>', '{->v:hlsearch ? ":nohl\\<CR>" : "\\<CR>"}()', { expr = true })
-- sane regexes
map({'n','v'}, '/', '/\\v', { noremap = true, silent = true })
-- don't jump when using *
map('n','*', '*<c-o>')
-- keep search matches in the middle of the window
map('n','n', 'nzzzv')
map('n','N', 'Nzzzv')
-- Same when jumping around
map('n','g;', 'g;zz', { silent = true })
-- replace ex mode map and use it for repeating 'q' macro
map('n','Q', '@q', { silent = true })
map('v','Q', '<cmd>norm @q<CR>', { silent = true })
-- Shortcut to close quickfix windows
map('n','<leader>a', '<cmd>windo lcl|ccl<CR>', { silent = true })
-- <Leader>q Closes the current buffer
map('n','<leader>q', '<cmd>bdelete<CR>', { silent = true })
-- Easier in-file navigation with Tab and S-Tab
map('n','<S-Tab>', '<C-U>')
map('n','<Tab>', '<C-D>')
-- more natural movement with wrap on
map({'n','v'},'j', 'gj', { noremap = true, silent = true })
map({'n','v'},'k', 'gk', { noremap = true, silent = true })
-- Easy buffer navigation
map('n','<C-h>', '<C-w>h', { silent = true })
map('n','<C-j>', '<C-w>j', { silent = true })
map('n','<C-k>', '<C-w>k', { silent = true })
map('n','<C-l>', '<C-w>l', { silent = true })
map('n','<up>', '<cmd>resize -2<CR>', { silent = true })
map('n','<down>', '<cmd>resize +2<CR>', { silent = true })
map('n','<left>', '<cmd>vertical resize -2<CR>', { silent = true })
map('n','<right>', '<cmd>vertical resize +2<CR>', { silent = true })
map({'n','i'},"<leader>s", "<cmd>HopChar2<cr>", { silent = true })
map('n',"<leader>w", "<cmd>HopWord<cr>", { silent = true })
map('n',"<silent><F6>", "<cmd>:set invspell<cr>", { silent = true })
--}}}

10
dot_gitconfig Normal file
View File

@ -0,0 +1,10 @@
[user]
name = Jan Eitzinger
email = jan@moebiusband.org
[pull]
rebase = false
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true

87
dot_tmux.conf Normal file
View File

@ -0,0 +1,87 @@
unbind C-b
set -g prefix C-a
bind C-a send-prefix
set -g base-index 1
set -ga terminal-overrides ",xterm-256color:Tc"
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
# Basic functions
bind -n M-n new-window
bind -n M-- split-window -v
bind -n M-| split-window -h
bind -n M-R command-prompt -I "" "rename-window '%%'"
bind -n M-X confirm-before "kill-window"
bind -n M-x confirm-before "kill-pane"
bind -n M-/ copy-mode
# ALT interface for switching windows
bind -n M-Tab last-window
bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n M-6 select-window -t 6
# Linux system clipboard
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -in -selection clipboard"
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "xclip -in -selection clipboard"
# enable vi mode
setw -g mode-keys vi
# don't allow tmux to rename the window based on commands running
set-option -wg automatic-rename off
# address vim mode switching delay (http://superuser.com/a/252717/65504)
set -s escape-time 0
# increase scrollback buffer size
set -g history-limit 50000
# tmux messages are displayed for 4 seconds
set -g display-time 4000
# refresh 'status-left' and 'status-right' more often
set -g status-interval 5
# upgrade $TERM
set -g default-terminal "screen-256color"
# emacs key bindings in tmux command prompt (prefix + :) are better than
# vi keys, even for vim users
set -g status-keys emacs
# focus events enabled for terminals that support them
set -g focus-events on
# super useful when using "grouped sessions" and multi-monitor setup
setw -g aggressive-resize on
set -g default-command /bin/zsh
set -g default-shell /bin/zsh
# status bar
set-option -g status-position top
set -g status-bg 'colour235'
set -g status-fg 'colour223'
set -g status-justify 'centre'
set -g status-left-length '100'
set -g status 'on'
set -g status-right-length '100'
# set -g window-status-separator '|'
set -g status-left '#[fg=colour232,bg=colour154] #S #[fg=colour222,bg=colour238] #W #[fg=colour8,bg=colour237] #(whoami) '
set -g status-right '#[fg=colour8,bg=colour237] %H:%M %a %d #[fg=colour222,bg=colour238] #h #[fg=colour232,bg=colour154] #{pomodoro_status} '
setw -g window-status-format '#[default] #I #W '
setw -g window-status-current-format '#[fg=colour222,bg=colour238] #I #W #F '
# List of plugins
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'tmux-plugins/tmux-logging'
set -g @plugin 'olimorris/tmux-pomodoro-plus'
set -g @plugin "jlipps/tmux-safekill"
# Initialize TMUX plugin manager
run -b '~/.tmux/plugins/tpm/tpm'

3
dot_tmux.conf.local Normal file
View File

@ -0,0 +1,3 @@
set -g default-command /bin/zsh
set -g default-shell /bin/zsh
set -g status-right '#[fg=colour8,bg=colour237] %H:%M %a %d #[fg=colour222,bg=colour238] #h #[fg=colour232,bg=colour154] #{battery_percentage}%% '

546
dot_vimrc Normal file
View File

@ -0,0 +1,546 @@
" vim: fdm=marker ts=2 sts=2 sw=2
if has('python3')
silent! python3 1
endif
let mapleader = "\<Space>"
let maplocalleader = "\\"
map <Space> <Leader>
let g:elite_mode=1
source ~/.vim/local.vim
" Plugins {{{
call plug#begin('~/.vim/plugged')
"###########
" Utility
"###########
Plug '~/.fzf'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } "{{{
let NERDTreeShowHidden=0
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
"}}}
Plug 'preservim/tagbar', { 'on': 'TagbarToggle' } "{{{
"}}}
Plug 'lifepillar/vim-mucomplete' "{{{
let g:mucomplete#chains = {
\ 'default': ['c-p', 'omni'],
\ 'markdown': ['keyp', 'thes', 'spel', 'dict'],
\ 'tex': ['keyp', 'ulti', 'spel', 'thes', 'dict']
\ }
inoremap <silent> <expr> <plug>MyCR mucomplete#ultisnips#expand_snippet("\<cr>")
imap <cr> <plug>MyCR
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <silent> <plug>(MUcompleteFwdKey) <right>
imap <right> <plug>(MUcompleteCycFwd)
inoremap <silent> <plug>(MUcompleteBwdKey) <left>
imap <left> <plug>(MUcompleteCycBwd)
"}}}
"Plug 'sirver/ultisnips' "{{{
"let g:UltiSnipsSnippetDirectories =[$HOME.'/.vim/plugged/vim-snippets/UltiSnips']
"let g:UltiSnipsExpandTrigger = "<f9>" " Do not use <tab>
"let g:UltiSnipsListSnippets = "<f10>" " Do not use <tab>
"let g:UltiSnipsJumpForwardTrigger = "<c-b>" " Do not use <c-j>
""}}}
Plug 'junegunn/fzf.vim' "{{{
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
let g:fzf_preview_window = ''
nnoremap <leader>e :Files<cr>
nnoremap <leader>E :History<cr>
nnoremap <leader>b :Buffer<cr>
nnoremap <leader>c :Commits<cr>
nnoremap <leader>s :Snippets<cr>
" nnoremap <leader>a :Ag<cr>
nnoremap <leader>g :Rg<cr>
nnoremap <leader>l :BLines<cr>
nnoremap <leader>L :Lines<cr>
nnoremap <leader>t :BTags<cr>
nnoremap <leader>T :Tags<cr>
nnoremap <leader>h :Helptags<cr>
"}}}
Plug 'junegunn/vim-easy-align' "{{{
xmap gl <Plug>(EasyAlign)
nmap gl <Plug>(EasyAlign)
"}}}
Plug 'easymotion/vim-easymotion' "{{{
let g:EasyMotion_do_mapping = 0
let g:EasyMotion_smartcase = 1
" map <Leader> <Plug>(easymotion-prefix)
nmap <Leader>s <Plug>(easymotion-overwin-f2)
map <Leader>w <Plug>(easymotion-bd-w)
nmap <Leader>w <Plug>(easymotion-overwin-w)
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
"}}}
Plug 'konfekt/fastfold' "{{{
nmap zuz <Plug>(FastFoldUpdate)
let g:fastfold_savehook = 1
let g:tex_fold_enabled = 1
let g:vimsyn_folding = 'af'
let g:javaScript_fold = 1
let g:perl_fold = 0
let g:php_folding = 0
" }}}
Plug 'tpope/vim-unimpaired' "{{{
"}}}
Plug 'mhinz/vim-grepper' "{{{
nnoremap <leader>g :Grepper -tool rg<cr>
nnoremap <leader>G :Grepper -tool ag<cr>
nmap gs <plug>(GrepperOperator)
xmap gs <plug>(GrepperOperator)
let g:grepper = {}
let g:grepper.tools = ['rg', 'ag', 'git', 'ack']
let g:grepper.jump = 1
let g:grepper.next_tool = '<leader>g'
let g:grepper.simple_prompt = 1
let g:grepper.quickfix = 0
"}}}
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-eunuch'
Plug 'vasconcelloslf/vim-interestingwords' "{{{
" nnoremap <silent> <leader>k :call InterestingWords('n')<cr>
" nnoremap <silent> <leader>K :call UncolorAllWords()<cr>
" nnoremap <silent> n :call WordNavigation('forward')<cr>
" nnoremap <silent> N :call WordNavigation('backward')<cr>
"}}}
"#############################
" Generic Programming Support
"#############################
Plug 'honza/vim-snippets'
Plug 'jiangmiao/auto-pairs' "{{{
let g:AutoPairsShortcutFastWrap='<C-e>'
let g:AutoPairsMapSpace = 0
imap <silent> <expr> <space> pumvisible()
\ ? "<space>"
\ : "<c-r>=AutoPairsSpace()<cr>"
let g:AutoPairsMapCR = 0
let g:AutoPairsMapSpace = 0
imap <silent> <expr> <space> pumvisible()
\ ? "<space>"
\ : "<c-r>=AutoPairsSpace()<cr>"
inoremap <silent> <expr> <plug>UltiExpand
\ mucomplete#ultisnips#expand_snippet("\<cr>")
imap <plug>MyCR <plug>UltiExpand<plug>AutoPairsReturn
imap <cr> <plug>MyCR
"}}}
Plug 'ntpeters/vim-better-whitespace' "{{{
let g:better_whitespace_filetypes_blacklist=['mail', 'diff', 'gitcommit', 'unite', 'qf', 'help']
"}}}
Plug 'tpope/vim-commentary'
Plug 'cespare/vim-toml'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'tobyS/vmustache'
Plug 'dense-analysis/ale' "{{{
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
highlight ALEErrorSign ctermbg=NONE ctermfg=red
highlight ALEWarningSign ctermbg=NONE ctermfg=yellow
let g:ale_lint_on_save = 1
let g:ale_fix_on_save = 1
let g:ale_lint_on_enter = 0
let g:ale_lint_on_text_changed = 'never'
set omnifunc=ale#completion#OmniFunc
let g:ale_linter_aliases = {'svelte': ['css', 'javascript']}
let g:ale_linters = {
\ 'javascript': ['standard'],
\ 'svelte': ['stylelint', 'eslint'],
\ 'go': ['go build', 'gometalinter']
\ }
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['prettier', 'eslint'],
\ 'svelte': ['eslint', 'prettier', 'prettier_standard'],
\ 'go': ['goimports']
\ }
let g:gometalinter_fast = ''
\ . ' --enable=vet'
\ . ' --enable=errcheck'
\ . ' --enable=ineffassign'
\ . ' --enable=goimports'
\ . ' --enable=misspell'
\ . ' --enable=lll --line-length=120'
let g:ale_go_gometalinter_options = '--disable-all --tests' . g:gometalinter_fast . ' --enable=golint'
"}}}
"#####################
" Markdown / Writing
"#####################
Plug 'dbmrq/vim-ditto' "{{{
" au FileType markdown,text,tex DittoOn
nmap <leader>di <Plug>ToggleDitto " Turn Ditto on and off
nmap =d <Plug>DittoNext " Jump to the next word
nmap -d <Plug>DittoPrev " Jump to the previous word
nmap +d <Plug>DittoGood " Ignore the word under the cursor
nmap _d <Plug>DittoBad " Stop ignoring the word under the cursor
nmap ]d <Plug>DittoMore " Show the next matches
nmap [d <Plug>DittoLess " Show the previous matches
"}}}
Plug 'kana/vim-textobj-user'
Plug 'reedes/vim-textobj-quote'
Plug 'reedes/vim-textobj-sentence'
Plug 'reedes/vim-wordy' "{{{
" let g:wordy_spell_dir = '~/.vim/spell/wordy'
"}}}
Plug 'reedes/vim-lexical' "{{{
let g:lexical#thesaurus = ['~/.vim/thesaurus/english.txt',]
let g:lexical#spellfile = ['~/.vim/spell/en.utf-8.add',]
let g:lexical#thesaurus_key = '<leader>t'
let g:lexical#dictionary_key = '<leader>k'
"}}}
Plug 'reedes/vim-litecorrect'
Plug 'reedes/vim-pencil' "{{{
let g:pencil#map#suspend_af = 'K'
"}}}
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-markdown'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } "{{{
let g:mkdp_refresh_slow = 1
"}}}
Plug 'lervag/vimtex' "{{{
let g:tex_flavor = 'latex'
"}}}
"#####################
" Productivity
"#####################
Plug 'fcpg/vim-waikiki' "{{{
let g:waikiki_roots = ['~/doc/vimwiki/']
let g:waikiki_default_maps = 1
nn <Leader>ww :e ~/doc/vimwiki/index.md<cr>
"}}}
Plug 'alok/notational-fzf-vim' "{{{
let g:nv_search_paths = ['~/doc/zettelkasten', '~/doc/wiki']
"}}}
"#####################
" Git Support
"#####################
Plug 'tpope/vim-fugitive' "{{{
nnoremap <Leader>gs :Gstatus<CR>
nnoremap <Leader>gr :Gremove<CR>
nnoremap <Leader>gl :Glog<CR>
nnoremap <Leader>gb :Gblame<CR>
nnoremap <Leader>gm :Gmove
nnoremap <Leader>gp :Ggrep
nnoremap <Leader>gR :Gread<CR>
nnoremap <Leader>gg :Git
nnoremap <Leader>gd :Gdiff<CR>
"}}}
Plug 'junegunn/gv.vim'
Plug 'mhinz/vim-signify' "{{{
let g:signify_vcs_list = [ 'git' ]
let g:signify_disable_by_default = 0
let g:signify_realtime = 0
nmap <F10> <Plug>(SignifyToggle)
"}}}
"#########################
" Web Programming Support
"#########################
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'mattn/emmet-vim'
Plug 'othree/html5.vim'
Plug 'lumiliet/vim-twig'
Plug 'evanleck/vim-svelte'
Plug 'jparise/vim-graphql'
Plug 'ap/vim-css-color'
"#########################
" Language support
"#########################
Plug 'vim-perl/vim-perl'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } "{{{
let g:go_addtags_transform = "camelcase"
autocmd FileType go nmap MM <Plug>(go-build)
autocmd FileType go nmap LL <Plug>(go-run)
autocmd FileType go nmap TT <Plug>(go-test)
autocmd FileType go nmap <Leader>i <Plug>(go-info)
"}}}
"#########################
" Theme / Interface
"#########################
let g:lightline = {'colorscheme': 'powerline'}
Plug 'itchyny/lightline.vim' "{{{
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified', 'pencil' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#statusline',
\ 'pencil': 'PencilMode'
\ },
\ }
"}}}
Plug 'morhetz/gruvbox'
call plug#end()
"}}}
" Vim sensible settings {{{
set nocompatible
set encoding=utf8
set lazyredraw
"Always show the status line
set laststatus=2
"Set incremental searching"
set incsearch
"highlighting of search matches
set hlsearch
"ignore case in search patterns
set ignorecase
"overwrite ignorecase if upper case chars
set smartcase
"Show line numbers
set number
"keep cursor in the same column
set nostartofline
"Write the old file out when switching between files.
set autowrite
"read file if changed outside
set autoread
"show line and column of cursor
set ruler
" Enable highlighting of the current line
" set cursorline
set wildmenu wildignorecase wildmode=list:longest,full
set history=1000
set completeopt+=menuone
set completeopt+=noselect
set cpt=.,w,b,t
" set completeopt+=noinsert
"Show command in bottom right portion of the screen
set showcmd
set noshowmode
set shortmess+=c
set belloff+=ctrlg
"Switch between buffers without saving
set hidden
set splitbelow
set splitright
set display+=lastline
"Enable code folding
" set foldenable foldmethod=syntax
"Ever notice a slight lag after typing the leader key + command?
"This lowers the timeout.
set timeoutlen=500 ttimeoutlen=50
"Hide mouse when typing
set mousehide
set mouse=a
"Tab stuff
set tabstop=4
set shiftwidth=4
set softtabstop=4
set smarttab
set expandtab
"Indent stuff
set smartindent
set autoindent
set breakindent
"Prefer a slightly higher line height
set linespace=3
set switchbuf=useopen
set updatetime=500
set synmaxcol=400
" Enable tab markers
let g:indentLine_char = '⦙'
"Better line wrapping
set nowrap
set formatoptions+=j
filetype plugin indent on
syntax on
" better backup, swap and undo storage
set noswapfile
set backup
set undofile
set backupdir=~/.vim/dirs/backup
set undodir=~/.vim/dirs/undo
set thesaurus=~/.vim/thesaurus/english.txt
set spellfile=~/.vim/spell/en.utf8.add
set spelllang=en_us
set diffopt+=algorithm:patience
set diffopt+=vertical
" hi SpellBad gui=underline guifg=red cterm=underline ctermfg=red
"}}}
" Theme and Styling {{{
if has('gui_running')
set guifont=BrutalistMono:h14
" Scrollbar junk
set guioptions=aAcei
set go-=T
set ballooneval
autocmd GUIEnter * set novisualbell t_vb=
endif
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
let g:gruvbox_contrast_dark = 'hard'
let g:gruvbox_italic=0
colorscheme gruvbox
set background=dark
"}}}
" Filetype settings {{{
function! Prose()
call pencil#init({'wrap': 'hard', 'autoformat': 1})
call lexical#init()
call litecorrect#init()
call textobj#quote#init()
call textobj#sentence#init()
colorscheme pencil
DittoOn
" manual reformatting shortcuts
nnoremap <buffer> <silent> Q gqap
xnoremap <buffer> <silent> Q gq
nnoremap <buffer> <silent> <leader>Q vapJgqap
" force top correction on most recent misspelling
nnoremap <buffer> <c-s> [s1z=<c-o>
inoremap <buffer> <c-s> <c-g>u<Esc>[s1z=`]A<c-g>u
" replace common punctuation
iabbrev <buffer> --
iabbrev <buffer> --- —
iabbrev <buffer> << «
iabbrev <buffer> >> »
" open most folds
setlocal foldlevel=6
" replace typographical quotes (reedes/vim-textobj-quote)
map <silent> <buffer> <leader>qc <Plug>ReplaceWithCurly
map <silent> <buffer> <leader>qs <Plug>ReplaceWithStraight
" highlight words (reedes/vim-wordy)
noremap <silent> <buffer> <F8> :<C-u>NextWordy<cr>
xnoremap <silent> <buffer> <F8> :<C-u>NextWordy<cr>
inoremap <silent> <buffer> <F8> <C-o>:NextWordy<cr>
endfunction
augroup CustomFiletype
autocmd BufNewFile,BufRead *.md set filetype=markdown
autocmd FileType python,vim,yaml setlocal foldmethod=indent
autocmd FileType qf wincmd J
augroup END
:autocmd! BufNewFile,BufRead * setlocal nowrap
:autocmd! BufNewFile,BufRead *.txt,*.md,*.tex setlocal wrap
autocmd BufNewFile,BufRead ~/.mutt/temp/* set noautoindent filetype=mail wm=0 tw=78 nonumber digraph nolist nofen
autocmd BufNewFile,BufRead /dev/shm/gopass.* setlocal noswapfile nobackup noundofile
autocmd FileType help wincmd L
autocmd FileType fugitive wincmd L
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" autocmd FileType markdown,mkd call Prose()
"}}}
" Mappings {{{
"allow deletion of previously entered data in insert mode
set backspace=indent,eol,start
" When pressing <Leader>cd switch to the directory of the open buffer
map <Leader>cd :cd %:p:h<CR>
"------ Disable Annoying Features ------
" Wtf is Ex Mode anyways?
nnoremap Q <nop>
" Annoying window
map q: :q
" Accidentally pressing Shift K will no longer open stupid man entry
noremap K <nop>
" Shortcut to close quickfix windows
nnoremap <silent> <leader>a :windo lcl\|ccl<CR>
"------ Buffer Navigation ------
" <Leader>q Closes the current buffer
nnoremap <silent> <Leader>q :bdelete<CR>
" replace ex mode map and use it for repeating 'q' macro
nnoremap Q @q
vnoremap Q :norm @q<cr>
" clear the search buffer when hitting return
nnoremap <silent> <CR> :nohlsearch<CR><CR>
if get(g:, 'elite_mode')
nnoremap <Up> :resize -2<CR>
nnoremap <Down> :resize +2<CR>
nnoremap <Left> :vertical resize -2<CR>
nnoremap <Right> :vertical resize +2<CR>
endif
" Easier in-file navigation with Tab and S-Tab
nnoremap <S-Tab> <C-U>
nnoremap <Tab> <C-D>
" Toggle all folds with F2
nnoremap <F2> zR
" nnoremap <F3> zM
nnoremap <F3> :PencilToggle<CR>
nnoremap <F4> :MUcompleteAutoToggle<CR>
nmap <F9> i<C-R>=strftime("%Y-%m-%d %H:%M")<CR><Esc>
imap <F9> <C-R>=strftime("%Y-%m-%d %H:%M")<CR>
map <C-t> :TagbarToggle<CR>
map <C-n> :NERDTreeToggle<CR>
" Easier split navigation
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" switch tabs with Ctrl left and right
nnoremap <C-right> :tabnext<CR>
nnoremap <C-left> :tabprevious<CR>
" and whilst in insert mode
inoremap <C-right> <Esc>:tabnext<CR>
inoremap <C-left> <Esc>:tabprevious<CR>
"------ Text Editing Utilities ------
" <Leader>U = Deletes Unwanted empty lines
nmap <Leader>U :g/^$/d<CR>
" <Leader>R = Converts tabs to spaces in document
nmap <Leader>R :retab<CR>
" gq will wrap lines, so gQ will unwrap lines
nmap gQ VipJ
command! -nargs=0 Prose call Prose()
"}}}