From 5bad8ef7a8f30b044c8f2fe4287ea916793e8786 Mon Sep 17 00:00:00 2001 From: Ellen Arvidsson Date: Wed, 18 Jun 2025 20:13:25 +0200 Subject: [PATCH] cleaning up --- .gitignore | 18 +- .vimrc | 410 +++++++++++--------- after/ftplugin/c.vim | 1 - after/indent/c.vim | 1 - {after/ftplugin => ftplugin}/arduino.vim | 0 ftplugin/c.vim | 14 + {after/ftplugin => ftplugin}/cabal.vim | 0 ftplugin/cpp.vim | 10 + {after/ftplugin => ftplugin}/haskell.vim | 0 {after/ftplugin => ftplugin}/html.vim | 0 {after/ftplugin => ftplugin}/java.vim | 0 {after/ftplugin => ftplugin}/javascript.vim | 0 {after/ftplugin => ftplugin}/json.vim | 0 ftplugin/markdown.vim | 2 + {after/ftplugin => ftplugin}/ocaml.vim | 0 {after/ftplugin => ftplugin}/p0.vim | 0 {after/ftplugin => ftplugin}/php.vim | 0 {after/ftplugin => ftplugin}/python.vim | 0 {after/ftplugin => ftplugin}/tex.vim | 0 {after/ftplugin => ftplugin}/text.vim | 0 ftplugin/typescript.vim | 1 + indent/c.vim | 8 + indent/cpp.vim | 6 + indent/markdown.vim | 3 + 24 files changed, 287 insertions(+), 187 deletions(-) delete mode 100644 after/ftplugin/c.vim delete mode 100644 after/indent/c.vim rename {after/ftplugin => ftplugin}/arduino.vim (100%) create mode 100644 ftplugin/c.vim rename {after/ftplugin => ftplugin}/cabal.vim (100%) create mode 100644 ftplugin/cpp.vim rename {after/ftplugin => ftplugin}/haskell.vim (100%) rename {after/ftplugin => ftplugin}/html.vim (100%) rename {after/ftplugin => ftplugin}/java.vim (100%) rename {after/ftplugin => ftplugin}/javascript.vim (100%) rename {after/ftplugin => ftplugin}/json.vim (100%) create mode 100644 ftplugin/markdown.vim rename {after/ftplugin => ftplugin}/ocaml.vim (100%) rename {after/ftplugin => ftplugin}/p0.vim (100%) rename {after/ftplugin => ftplugin}/php.vim (100%) rename {after/ftplugin => ftplugin}/python.vim (100%) rename {after/ftplugin => ftplugin}/tex.vim (100%) rename {after/ftplugin => ftplugin}/text.vim (100%) create mode 100644 ftplugin/typescript.vim create mode 100644 indent/c.vim create mode 100644 indent/cpp.vim create mode 100644 indent/markdown.vim diff --git a/.gitignore b/.gitignore index fad4951..f689441 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,19 @@ -# Created by https://www.gitignore.io/api/vim -# Edit at https://www.gitignore.io/?templates=vim - -### Vim ### -# Swap +# vim swap [._]*.s[a-v][a-z] [._]*.sw[a-p] [._]s[a-rt-v][a-z] [._]ss[a-gi-z] [._]sw[a-p] -# Session +# session Session.vim -# Temporary +# temporary .netrwhist *~ -# Auto-generated tag files -tags -# Persistent undo +# persistent undo [._]*.un~ -# End of https://www.gitignore.io/api/vim +# handled by plugin manager (plugged) +autoload/ +plugged/ diff --git a/.vimrc b/.vimrc index 62c18c2..0d9eb2a 100644 --- a/.vimrc +++ b/.vimrc @@ -3,53 +3,37 @@ filetype off " required call plug#begin('~/.vim/plugged') +" reload config files automatically +Plug 'xolox/vim-reload' + " Ctrlp for fuzzy file search Plug 'ctrlpvim/ctrlp.vim' " File browser Plug 'scrooloose/nerdtree' -" tab support for nerdtree -Plug 'jistr/vim-nerdtree-tabs' - -" Snippet handler -" Plug 'SirVer/ultisnips' - -" snippets for ultisnips -" Plug 'honza/vim-snippets' - -" supertab for completion -" Plug 'ervandew/supertab' - -" YouCompleteMe auto-completion -" Plug 'Valloric/YouCompleteMe' - " More clever matching for % key Plug 'tmhedberg/matchit' -" JavaScript syntax highlighting -" Plug 'pangloss/vim-javascript' - -" jsx syntax highlighting -" Plug 'mxw/vim-jsx' - -" Language server protocol linter -" Plug 'w0rp/ale' - " fugitive.vim git integration Plug 'tpope/vim-fugitive' -" Clojure highlight -" Plug 'guns/vim-clojure-static' - " Surround Plug 'tpope/vim-surround' " Repeat of plugin commands Plug 'tpope/vim-repeat' -" Ack.vim -- can use ag with this -Plug 'mileszs/ack.vim' +" LSP support +Plug 'yegappan/lsp' + +" more commplete +Plug 'girishji/vimcomplete' + +" snippet support +Plug 'hrsh7th/vim-vsnip' +Plug 'hrsh7th/vim-vsnip-integ' +Plug 'rafamadriz/friendly-snippets' " Haskell syntax Plug 'neovimhaskell/haskell-vim' @@ -60,6 +44,8 @@ Plug 'leafgarland/typescript-vim' call plug#end() " All of your Plugins must be added before the following line +language en_US.UTF-8 + filetype plugin indent on " required syntax on @@ -83,91 +69,21 @@ set mouse=a set history=1000 set undolevels=1000 + " highlight search results set hlsearch " show tabs and spaces set list -set listchars=tab:>··,trail:· +set listchars=space:·,tab:..>,trail:· -hi SpecialKey ctermfg=darkgrey - -" make delimitMate insert another line when -" closing curlys for example -let delimitMate_expand_cr = 1 - -" make YCM load with python 3 -let g:ycm_server_python_interpreter = '/usr/bin/python2' - -" YCM non-arch package install path to ycm extra conf -"let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py" - -" YCM extra configuration for arch specific YCM package -"let g:ycm_global_ycm_extra_conf = '/usr/share/vim/vimfiles/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py' -"let g:ycm_path_to_python_interpreter = '/usr/bin/python2' - -" Eclim completion method should be set to omnifunc in order to work with YCM -let g:EclimCompletionMethod = 'omnifunc' - -" let syntastic handle the syntax checking -let g:ycm_show_diagnostics_ui = 0 - -" make YCM compatible with UltiSnips (using supertab) -let g:ycm_key_list_select_completion = ['', ''] -let g:ycm_key_list_previous_completion = ['', ''] -let g:SuperTabDefaultCompletionType = '' - -" better key bindings for UltiSnipsExpandTrigger -let g:UltiSnipsExpandTrigger = "" -let g:UltiSnipsJumpForwardTrigger = "" -let g:UltiSnipsJumpBackwardTrigger = "" - -" Leader maps -let mapleader="," -let maplocalleader="\\" -map n NERDTreeTabsToggle autocmd VimEnter * wincmd p -"for ino completion -"autocmd BufNewFile,BufRead *.ino setlocal ft=arduino - -" IMPORTANT: grep will sometimes skip displaying the file name if you -" search in a singe file. This will confuse Latex-Suite. Set your grep -" program to always generate a file-name. -" set grepprg=grep\ -nH\ $* - -" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to -" 'plaintex' instead of 'tex', which results in vim-latex not being loaded. -" The following changes the default filetype back to 'tex': -" let g:tex_flavor='latex' - -" Short commands ----------------------- - -" Searching for visually selected text -vnoremap // y/"" - -" For latex compiling -augroup latex_macros " { - autocmd! - autocmd FileType tex :nnoremap c :w :!latexmk -pdf % - autocmd FileType tex :nnoremap v :!evince %:r.pdf & -augroup END " } - -" JavaScript macros -augroup html_macros " { - autocmd! - autocmd FileType html :nnoremap c :w :silent !firefox %:p & -augroup END " } - -augroup javascript_macros " { - autocmd! - autocmd FileType javascript.jsx :nnoremap df :YcmCompleter GoTo -augroup END " } - " JSON macros +" TODO move to ftplugin augroup json_macros " { autocmd! autocmd FileType json :nnoremap fm :%!python -m json.tool @@ -185,82 +101,11 @@ augroup c_stuff " { autocmd BufNewFile,BufRead *.h set ft=c augroup END " } -augroup verona_stuff " { - autocmd! - autocmd BufNewFile,BufRead *.verona set ft=typescript -augroup end " } -" Function for toggling the relative line numbers -function ToggleRelative() - if &relativenumber==1 - set norelativenumber - else - set relativenumber - endif -endfunction - -" Macros for toggling relative number lines -noremap :call ToggleRelative() -inoremap :call ToggleRelative() - -function GrepAskForDir(specifier) - let cw = expand("") - let cwd = getcwd() - call inputsave() - let dir = input('Grep for word ' . cw . 'in dir: ') - call inputrestore() - execute 'Ack '. a:specifier . ' ' . dir -endfunction - -noremap g :call GrepAskForDir(expand("")) - -function SetIdentWidth() - call inputsave() - let l:width = input('Set ident: ') - call inputrestore() - if l:width=='' - set tabstop=8 shiftwidth=8 noexpandtab - else - let l:numw = str2nr(l:width, 10) - execute 'set softtabstop=' . l:numw . ' shiftwidth=' . l:numw . ' expandtab' - endif -endfunction - -noremap i :call SetIdentWidth() -noremap r :call ToggleRelative() - -" Automatically user relative lines when not in insert mode -" au InsertLeave * :set relativenumber -" au InsertEnter * :set norelativenumber - - -" Syntastic settings -"let g:syntastic_mode_map = { -" \ "mode": "active", -" \ "passive_filetypes": ["java", "scala"] } - -" Ale linter settings -let g:ale_linters = { -\ 'javascript': ['standard'], -\} -let g:ale_fixers = {'javascript': ['standard']} - -"let g:ale_lint_on_text_changed = 'never' " Ctrl-p settings -"let g:ctrlp_max_files = 30000 let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard'] -let g:ale_linters_explicit = 1 - -" hlsearch -noremap h :nohlsearch - -" Ack -if executable('ag') - let g:ackprg = 'ag --vimgrep' -endif - digraphs \- 8866 digraphs -\ 8867 digraphs !( 8840 @@ -274,4 +119,221 @@ digraphs /) 8716 " Markdown let g:markdown_fenced_languages = ['python', 'typescript', 'javascript', 'haskell'] -colorscheme habamax + +" ############## AUTOCOMPLETE STUFF ############## + +" ############## autocomplete + +let autocomplete_opts = #{ + \ vsnip : #{ enable: v:true } + \ } + +" Expand +imap vsnip#expandable() ? '(vsnip-expand)' : '' +smap vsnip#expandable() ? '(vsnip-expand)' : '' + +" Expand or jump +imap vsnip#available(1) ? '(vsnip-expand-or-jump)' : '' +smap vsnip#available(1) ? '(vsnip-expand-or-jump)' : '' + +" Jump forward or backward +imap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' +smap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' +imap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' +smap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' + +" Select or cut text to use as $TM_SELECTED_TEXT in the next snippet. +" See https://github.com/hrsh7th/vim-vsnip/pull/50 +" nmap s (vsnip-select-text) +" xmap s (vsnip-select-text) +" nmap S (vsnip-cut-text) +" xmap S (vsnip-cut-text) + +" If you want to use snippet for multiple filetypes, you can `g:vsnip_filetypes` for it. +"let g:vsnip_filetypes = {} + + +" lsp support stuff +let g:lspOpts = #{ + \ aleSupport: v:false, + \ autoComplete: v:true, + \ autoHighlight: v:false, + \ autoHighlightDiags: v:true, + \ autoPopulateDiags: v:false, + \ completionMatcher: 'case', + \ completionMatcherValue: 1, + \ diagSignErrorText: 'E>', + \ diagSignHintText: 'H>', + \ diagSignInfoText: 'I>', + \ diagSignWarningText: 'W>', + \ echoSignature: v:false, + \ hideDisabledCodeActions: v:false, + \ highlightDiagInline: v:false, + \ hoverInPreview: v:false, + \ ignoreMissingServer: v:false, + \ keepFocusInDiags: v:true, + \ keepFocusInReferences: v:true, + \ completionTextEdit: v:true, + \ diagVirtualTextAlign: 'above', + \ diagVirtualTextWrap: 'default', + \ noNewlineInCompletion: v:false, + \ omniComplete: v:null, + \ outlineOnRight: v:false, + \ outlineWinSize: 20, + \ semanticHighlight: v:false, + \ showDiagInBalloon: v:true, + \ showDiagInPopup: v:true, + \ showDiagOnStatusLine: v:false, + \ showDiagWithSign: v:true, + \ showDiagWithVirtualText: v:false, + \ showInlayHints: v:false, + \ showSignature: v:true, + \ snippetSupport: v:false, + \ ultisnipsSupport: v:false, + \ useBufferCompletion: v:false, + \ usePopupInCodeAction: v:false, + \ useQuickfixForLocations: v:false, + \ vsnipSupport: v:false, + \ bufferCompletionTimeout: 100, + \ customCompletionKinds: v:false, + \ completionKinds: {}, + \ filterCompletionDuplicates: v:false, + \ } + +autocmd User LspSetup call LspOptionsSet(lspOpts) + + +let lspServers = [#{ + \ name: 'clang', + \ filetype: ['c', 'cpp'], + \ path: '/usr/bin/clangd', + \ args: ['--background-index', '--header-insertion=never'] + \ }] +autocmd User LspSetup call LspAddServer(lspServers) + + +" ============ LogE_* ================= + +" Toggle relative line numbers +function LogE_ToggleRelative() + if &relativenumber==1 + set norelativenumber + else + set relativenumber + endif +endfunction + +" grep for arg in current or specified dir +function LogE_GrepAskForDir(what) + call inputsave() + let dir = input('grep -r "' . a:what . '" in directory (default is ./): ') + call inputrestore() + + if !dir + dir = './' + endif + + execute 'grep -r ' . a:what . ' ' . dir +endfunction + +" ask for input of number, and set indentation width accordingly +" if input is '', setting defaults to +" set tabstop=8 shiftwidth=8 noexpandtab +" if input is 'n', settings are set as +" set softtabstop=n shiftwidth=n expandtab +function LogE_SetIndentWidth() + call inputsave() + let l:width = input('Set ident: ') + call inputrestore() + if l:width=='' + set tabstop=8 shiftwidth=8 noexpandtab + else + let l:numw = str2nr(l:width, 10) + execute 'set softtabstop=' . l:numw . ' shiftwidth=' . l:numw . ' expandtab' + endif +endfunction + +" terminal theme color adjustments +function LogE_ColorAdjust_TomorrowDark() + hi SpecialKey ctermfg=darkgrey + hi ColorColumn ctermbg=darkgrey +endfunction + +function LogE_ColorAdjust_TomorrowLight() + hi SpecialKey ctermfg=225 + hi ColorColumn ctermbg=225 " light pinkish +endfunction + +call LogE_ColorAdjust_TomorrowDark() + +let g:ColorAdjustments = [ + \ ['tomorrowDark', function("LogE_ColorAdjust_TomorrowDark")], + \ ['tomorrowLight', function("LogE_ColorAdjust_TomorrowLight")], + \ ] + +let g:CurrColorAdjust=g:ColorAdjustments[0][0] + +function LogE_ColorAdjust_Rotate() + let found=v:false + for kv in g:ColorAdjustments + if found + let g:CurrColorAdjust=kv[0] + call kv[1]() + return + endif + + if kv[0] == g:CurrColorAdjust + let found=v:true + endif + endfor + + " NOTE: will only end up here if we need to wrap around the list of + " color adjustments + let wrap=g:ColorAdjustments[0] + let g:CurrColorAdjust=wrap[0] + call wrap[1]() + return +endfunction + +" this is called from ftplugin scripts +function LogE_LspDiagShowSignToggle() + if g:lspOpts.showDiagWithSign + let g:lspOpts.showDiagWithSign = v:false + else + let g:lspOpts.showDiagWithSign = v:true + endif + + call LspOptionsSet(g:lspOpts) +endfunction + +" ================= key mappings ================ + +" is , (comma) +" is \ (backslash) +let mapleader="," +let maplocalleader="\\" + +" ----------- NORMAL MODE ------------------ +" NERDTree* +noremap tn :NERDTreeToggle +noremap fn :NERDTreeFocus +noremap n :NERDTreeFocus + +" rotate through color adjustments +noremap ta :call LogE_ColorAdjust_Rotate() + +" line numbers toggle +noremap :call LogE_ToggleRelative() + +" grep current word +noremap gcw :call LogE_GrepAskForDir(expand("")) + +" set indentation width +noremap si :call LogE_SetIndentWidth() + +" ------------- VISUAL MODE --------------- +" Searching for visually selected text +vnoremap // y/"" + +" ------------- INSERT MODE --------------- +inoremap :call LogE_ToggleRelative() diff --git a/after/ftplugin/c.vim b/after/ftplugin/c.vim deleted file mode 100644 index 8edfdc8..0000000 --- a/after/ftplugin/c.vim +++ /dev/null @@ -1 +0,0 @@ -set softtabstop=8 shiftwidth=8 noexpandtab diff --git a/after/indent/c.vim b/after/indent/c.vim deleted file mode 100644 index 5996981..0000000 --- a/after/indent/c.vim +++ /dev/null @@ -1 +0,0 @@ -set cinoptions=(4 diff --git a/after/ftplugin/arduino.vim b/ftplugin/arduino.vim similarity index 100% rename from after/ftplugin/arduino.vim rename to ftplugin/arduino.vim diff --git a/ftplugin/c.vim b/ftplugin/c.vim new file mode 100644 index 0000000..2adbd54 --- /dev/null +++ b/ftplugin/c.vim @@ -0,0 +1,14 @@ +map dd :LspDiagCurrent +map dn :LspDiagNext +map dp :LspDiagPrev + +map er :LspRename + +" toggle show diagnostic indicator next to line numbers +map td :call LogE_LspDiagShowSignToggle() + +" ctags file names +set tags=tags; + + +set colorcolumn=+0 diff --git a/after/ftplugin/cabal.vim b/ftplugin/cabal.vim similarity index 100% rename from after/ftplugin/cabal.vim rename to ftplugin/cabal.vim diff --git a/ftplugin/cpp.vim b/ftplugin/cpp.vim new file mode 100644 index 0000000..34c8e83 --- /dev/null +++ b/ftplugin/cpp.vim @@ -0,0 +1,10 @@ +set softtabstop=8 shiftwidth=8 noexpandtab + +map dd :LspDiagCurrent +map dn :LspDiagNext +map dp :LspDiagPrev + +map er :LspRename + +" toggle show diagnostic indicator next to line numbers +map td :call LogE_LspDiagShowSignToggle() diff --git a/after/ftplugin/haskell.vim b/ftplugin/haskell.vim similarity index 100% rename from after/ftplugin/haskell.vim rename to ftplugin/haskell.vim diff --git a/after/ftplugin/html.vim b/ftplugin/html.vim similarity index 100% rename from after/ftplugin/html.vim rename to ftplugin/html.vim diff --git a/after/ftplugin/java.vim b/ftplugin/java.vim similarity index 100% rename from after/ftplugin/java.vim rename to ftplugin/java.vim diff --git a/after/ftplugin/javascript.vim b/ftplugin/javascript.vim similarity index 100% rename from after/ftplugin/javascript.vim rename to ftplugin/javascript.vim diff --git a/after/ftplugin/json.vim b/ftplugin/json.vim similarity index 100% rename from after/ftplugin/json.vim rename to ftplugin/json.vim diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim new file mode 100644 index 0000000..2e22164 --- /dev/null +++ b/ftplugin/markdown.vim @@ -0,0 +1,2 @@ +set colorcolumn=+1 + diff --git a/after/ftplugin/ocaml.vim b/ftplugin/ocaml.vim similarity index 100% rename from after/ftplugin/ocaml.vim rename to ftplugin/ocaml.vim diff --git a/after/ftplugin/p0.vim b/ftplugin/p0.vim similarity index 100% rename from after/ftplugin/p0.vim rename to ftplugin/p0.vim diff --git a/after/ftplugin/php.vim b/ftplugin/php.vim similarity index 100% rename from after/ftplugin/php.vim rename to ftplugin/php.vim diff --git a/after/ftplugin/python.vim b/ftplugin/python.vim similarity index 100% rename from after/ftplugin/python.vim rename to ftplugin/python.vim diff --git a/after/ftplugin/tex.vim b/ftplugin/tex.vim similarity index 100% rename from after/ftplugin/tex.vim rename to ftplugin/tex.vim diff --git a/after/ftplugin/text.vim b/ftplugin/text.vim similarity index 100% rename from after/ftplugin/text.vim rename to ftplugin/text.vim diff --git a/ftplugin/typescript.vim b/ftplugin/typescript.vim new file mode 100644 index 0000000..659b14e --- /dev/null +++ b/ftplugin/typescript.vim @@ -0,0 +1 @@ +set softtabstop=2 shiftwidth=2 expandtab diff --git a/indent/c.vim b/indent/c.vim new file mode 100644 index 0000000..a1e1747 --- /dev/null +++ b/indent/c.vim @@ -0,0 +1,8 @@ +set softtabstop=8 shiftwidth=8 noexpandtab + +set cinoptions=(4,+4,m1,:0 + +" For cpp: E-s, + +set fo=croqlj/ +set tw=80 diff --git a/indent/cpp.vim b/indent/cpp.vim new file mode 100644 index 0000000..5b72e3d --- /dev/null +++ b/indent/cpp.vim @@ -0,0 +1,6 @@ +set cinoptions=(4,:0 + +set fo=croqlj/ +set tw=80 + +set colorcolumn=+0 diff --git a/indent/markdown.vim b/indent/markdown.vim new file mode 100644 index 0000000..40bd248 --- /dev/null +++ b/indent/markdown.vim @@ -0,0 +1,3 @@ +set tw=79 + +set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab