diff --git a/home/vim/default.nix b/home/vim/default.nix index 11ae974..ec208b9 100644 --- a/home/vim/default.nix +++ b/home/vim/default.nix @@ -45,4 +45,10 @@ extraConfig = builtins.readFile ./init.vim; }; + + xdg.configFile = { + "nvim/plugin" = { + source = ./plugin; + }; + }; } diff --git a/home/vim/plugin/abbreviations.vim b/home/vim/plugin/abbreviations.vim new file mode 100644 index 0000000..5d36434 --- /dev/null +++ b/home/vim/plugin/abbreviations.vim @@ -0,0 +1,5 @@ +" A few useful sets of abbreviations + +" A few things that are hard to write in ASCII +abbreviate (R) © +abbreviate (TM) ™ diff --git a/home/vim/plugin/mappings/leader.vim b/home/vim/plugin/mappings/leader.vim new file mode 100644 index 0000000..0aba0b2 --- /dev/null +++ b/home/vim/plugin/mappings/leader.vim @@ -0,0 +1,6 @@ +" Map leader to space (needs the noremap trick to avoid moving the cursor) +nnoremap +let mapleader=" " + +" Map localleader to '!' (if I want to filter text, I use visual mode) +let maplocalleader="!" diff --git a/home/vim/plugin/numbertoggle.vim b/home/vim/plugin/numbertoggle.vim new file mode 100644 index 0000000..d9a969d --- /dev/null +++ b/home/vim/plugin/numbertoggle.vim @@ -0,0 +1,13 @@ +" Idea for toggling taken from jeffkreeftmeijer + +" Show line numbers +set number + +augroup numbertoggle + autocmd! + " Toggle numbers between relative and absolute when changing buffers + autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu | set rnu | endif + autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif + " Disable line numbers and relative line numbers in terminal + autocmd TermOpen * setlocal nonu nornu +augroup END diff --git a/home/vim/plugin/settings/ale.vim b/home/vim/plugin/settings/ale.vim new file mode 100644 index 0000000..23c9138 --- /dev/null +++ b/home/vim/plugin/settings/ale.vim @@ -0,0 +1,24 @@ +" Always display the sign column to avoid moving the buffer all the time +let g:ale_sign_column_always=1 + +" Change the way ALE display messages +let g:ale_echo_msg_info_str='I' +let g:ale_echo_msg_warning_str='W' +let g:ale_echo_msg_error_str='E' + +" The message displayed in the command line area +let g:ale_echo_msg_format='[%linter%][%severity%]%(code):% %s' + +" The message displayed in the location list +let g:ale_loclist_msg_format='[%linter%]%(code):% %s' + +" Don't lint every time I change the buffer +let g:ale_lint_on_text_changed=0 +" Don't lint on leaving insert mode +let g:ale_lint_on_insert_leave=0 +" Don't lint on entering a buffer +let g:ale_lint_on_enter=0 +" Do lint on save +let g:ale_lint_on_save=1 +" Lint on changing the filetype +let g:ale_lint_on_filetype_changed=1 diff --git a/home/vim/plugin/settings/betterwhitespace.vim b/home/vim/plugin/settings/betterwhitespace.vim new file mode 100644 index 0000000..71ac74c --- /dev/null +++ b/home/vim/plugin/settings/betterwhitespace.vim @@ -0,0 +1,5 @@ +" Enable trailing whitespace high-lighting +let g:better_whitespace_enabled=1 + +" Strip trailing whitespace on file-save +let g:strip_whitespace_on_save=1 diff --git a/home/vim/plugin/settings/fastfold.vim b/home/vim/plugin/settings/fastfold.vim new file mode 100644 index 0000000..a1f1787 --- /dev/null +++ b/home/vim/plugin/settings/fastfold.vim @@ -0,0 +1,5 @@ +" Intercept all fold commands +let g:fastfold_fold_command_suffixes=[ + \ 'x', 'X', 'a', 'A', 'o', 'O', 'c', 'C', + \ 'r', 'R', 'm', 'M', 'i', 'n', 'N' + \ ] diff --git a/home/vim/plugin/settings/fzf.vim b/home/vim/plugin/settings/fzf.vim new file mode 100644 index 0000000..7125b70 --- /dev/null +++ b/home/vim/plugin/settings/fzf.vim @@ -0,0 +1,8 @@ +" Use a floating window when availble +if has('nvim-0.4.0') || has("patch-8.2.0191") + let g:fzf_layout = { 'window': { + \ 'width': 0.9, + \ 'height': 0.7, + \ 'highlight': 'Comment', + \ 'rounded': v:false } } +endif diff --git a/home/vim/plugin/settings/gruvbox.vim b/home/vim/plugin/settings/gruvbox.vim new file mode 100644 index 0000000..4b14437 --- /dev/null +++ b/home/vim/plugin/settings/gruvbox.vim @@ -0,0 +1,5 @@ +" Use the high-contrast theme +let g:gruvbox_contrast_dark='hard' + +" Enable italics because urxvt supports them +let g:gruvbox_italic=1 diff --git a/home/vim/plugin/settings/lightline.vim b/home/vim/plugin/settings/lightline.vim new file mode 100644 index 0000000..0513160 --- /dev/null +++ b/home/vim/plugin/settings/lightline.vim @@ -0,0 +1,81 @@ +" Initialise light-line setting structure +let g:lightline={} + +" Use the wombat colorscheme +let g:lightline.colorscheme='onedark' + +" Status-line for active buffer +let g:lightline.active={ + \ 'left': [ + \ [ 'mode', 'paste' ], + \ [ 'gitbranch', 'readonly', 'filename', 'modified' ], + \ [ 'spell' ], + \ ], + \ 'right': [ + \ [ 'lineinfo' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype' ], + \ [ 'linter_check', 'linter_errors', 'linter_warn', 'linter_ok' ], + \ [ 'ctags_status' ], + \ ] + \ } + +" Status-line for inactive buffer +let g:lightline.inactive={ + \ 'left': [ + \ [ 'filename' ], + \ ], + \ 'right': [ + \ [ 'lineinfo' ], + \ [ 'percent' ], + \ ], + \ } + +" Which component should be written using which function +let g:lightline.component_function={ + \ 'readonly': 'LightlineReadonly', + \ 'modified': 'LightlineModified', + \ 'gitbranch': 'LightlineFugitive', + \ } + +" Which component can be expanded by using which function +let g:lightline.component_expand={ + \ 'linter_check': 'lightline#ale#checking', + \ 'linter_warn': 'lightline#ale#warnings', + \ 'linter_errors': 'lightline#ale#errors', + \ 'linter_ok': 'lightline#ale#ok', + \ } + +" How to color custom components +let g:lightline.component_type={ + \ 'readonly': 'error', + \ 'linter_checking': 'left', + \ 'linter_warn': 'warning', + \ 'linter_errors': 'error', + \ 'linter_ok': 'left', + \ } + +" Show pretty icons instead of text for linting status +let g:lightline#ale#indicator_checking='⏳' +let g:lightline#ale#indicator_warnings='◆' +let g:lightline#ale#indicator_errors='✗' +let g:lightline#ale#indicator_ok='✓' + +" Show a lock icon when editing a read-only file when it makes sense +function! LightlineReadonly() + return &ft!~?'help\|vimfiler\|netrw' && &readonly ? '' : '' +endfunction + +" Show a '+' when the buffer is modified, '-' if not, when it makes sense +function! LightlineModified() + return &ft=~'help\|vimfiler\|netrw' ? '' : &modified ? '+' : &modifiable ? '' : '-' +endfunction + +" Show branch name with nice icon in status line, when it makes sense +function! LightlineFugitive() + if &ft!~?'help\|vimfiler\|netrw' && exists('*fugitive#head') + let branch=fugitive#head() + return branch!=#'' ? ' '.branch : '' + endif + return '' +endfunction diff --git a/home/vim/plugin/settings/pandoc.vim b/home/vim/plugin/settings/pandoc.vim new file mode 100644 index 0000000..71b750c --- /dev/null +++ b/home/vim/plugin/settings/pandoc.vim @@ -0,0 +1,20 @@ +" Which code-block languages should I expect to be high-lighted. +let g:pandoc#syntax#codeblocks#embeds#langs=[ + \ "bash=sh", + \ "c", + \ "cpp", + \ "go", + \ "haskell", + \ "python", + \ "rust", + \ "sh", + \ "vim", + \ "yaml", + \ "tex", + \ "toml", + \ "perl", + \ "json", + \ "latex=tex", + \ "make", + \ "makefile=make", + \ ] diff --git a/home/vim/plugin/signtoggle.vim b/home/vim/plugin/signtoggle.vim new file mode 100644 index 0000000..c2f0183 --- /dev/null +++ b/home/vim/plugin/signtoggle.vim @@ -0,0 +1,8 @@ +augroup signtoggle + autocmd! + " Only show the sign column for the current focused buffer + autocmd BufEnter,FocusGained,WinEnter * set signcolumn=yes + autocmd BufLeave,FocusLost,WinLeave * set signcolumn=no + " Disable the sign column in terminal + autocmd TermOpen * setlocal signcolumn=no +augroup END