Skip to content

Instantly share code, notes, and snippets.

@DKurilo
Last active March 26, 2023 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DKurilo/5595e8a5af7e7aca7ea464b1a40daefe to your computer and use it in GitHub Desktop.
Save DKurilo/5595e8a5af7e7aca7ea464b1a40daefe to your computer and use it in GitHub Desktop.
" https://github.com/neoclide/coc.nvim#example-vim-configuration
set hidden
set cmdheight=2
set shortmess+=c
" This is only necessary if you use "set termguicolors".
set termguicolors
" Coc.nvim
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: There's always complete item selected by default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,typescriptreact,javascript,javascriptreact,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Run the Code Lens action on the current line.
nmap <leader>cl <Plug>(coc-codelens-action)
" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocActionAsync('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Mappings for CoCList
" Show all diagnostics.
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
"end of Coc.nvim
set mouse=
set nocompatible
set backspace=indent,eol,start
set noerrorbells visualbell t_vb=
set nobackup
set nowritebackup
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
set noautoread
" To load ~/.bash_profile
let &shell='/usr/local/bin/bash --rcfile ~/.bash_profile'
" Terminal mode:
tnoremap ˙ <C-w>h
tnoremap <C-w>j
tnoremap ˚ <C-w>k
tnoremap ¬ <C-w>l
" Insert mode:
inoremap ˙ <Esc><C-w>h
inoremap <Esc><C-w>j
inoremap ˚ <Esc><C-w>k
inoremap ¬ <Esc><C-w>l
" Visual mode:
vnoremap ˙ <Esc><C-w>h
vnoremap <Esc><C-w>j
vnoremap ˚ <Esc><C-w>k
vnoremap ¬ <Esc><C-w>l
" Normal mode:
nnoremap ˙ <C-w>h
nnoremap <C-w>j
nnoremap ˚ <C-w>k
nnoremap ¬ <C-w>l
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
set clipboard=unnamed
syntax on
set re=0
colorscheme maria
set number
set relativenumber
set ruler
set expandtab
set shiftwidth=4
set softtabstop=4
set statusline=%t[%{strlen(&fenc)?&fenc:'none'},%{&ff}]%h%m%r%y%=%c%{coc#status()},%{get(b:,'coc_current_function','')},%l/%L\ %P
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
set laststatus=2
set wildmenu
set display+=lastline
autocmd FileType javascript set softtabstop=2
autocmd FileType javascriptreact set softtabstop=2
autocmd FileType typescript set softtabstop=2
autocmd FileType typescriptreact set softtabstop=2
autocmd FileType javascript set shiftwidth=2
autocmd FileType javascriptreact set shiftwidth=2
autocmd FileType typescript set shiftwidth=2
autocmd FileType typescriptreact set shiftwidth=2
autocmd FileType json set softtabstop=2
autocmd FileType json set shiftwidth=2
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_mode_map = { 'mode': 'active' }
let g:syntastic_haskell_checkers = ['hlint']
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
let g:terraform_align=1
let g:terraform_fold_sections=0
let g:terraform_fmt_on_save=1
let g:syntastic_terraform_tffilter_plan = 1
let g:terraform_completion_keys = 1
let g:terraform_registry_module_completion = 0
let g:yaml_formatter_indent_collection=1
autocmd FileType yaml setlocal tabstop=4
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" au FileType haskell nnoremap <buffer> <F2> :HdevtoolsType<CR>
" au FileType haskell nnoremap <buffer> <silent> <F3> :HdevtoolsInfo<CR>
" au FileType haskell nnoremap <buffer> <silent> <F4> :HdevtoolsClear<CR>
" let g:vim_annotations_offset = '/.liquid/'
set rtp+=$GOROOT/misc/vim
filetype plugin indent on
" Haskell
autocmd BufWrite *.hs :Autoformat
autocmd FileType haskell let b:autoformat_autoindent=0
let g:formatdef_my_haskell = '"ormolu"'
let g:formatters_haskell = ['my_haskell']
autocmd BufWrite *.html :Autoformat
autocmd BufWrite *.json :Autoformat
" Python
" default Black line length is 88, let's tell it for flake
let g:syntastic_python_pylint_post_args="--max-line-length=88"
let g:syntastic_python_flake8_args="--max-line-length=88"
" autocmd BufWritePre *.py execute ':Black'
" let g:black_skip_string_normalization = 1
" turn off formatting for Python
autocmd! BufWrite *.py
" Subscripts, superscripts
execute "digraphs as " . 0x2090
execute "digraphs es " . 0x2091
execute "digraphs hs " . 0x2095
execute "digraphs is " . 0x1D62
execute "digraphs js " . 0x2C7C
execute "digraphs ks " . 0x2096
execute "digraphs ls " . 0x2097
execute "digraphs ms " . 0x2098
execute "digraphs ns " . 0x2099
execute "digraphs os " . 0x2092
execute "digraphs ps " . 0x209A
execute "digraphs rs " . 0x1D63
execute "digraphs ss " . 0x209B
execute "digraphs ts " . 0x209C
execute "digraphs us " . 0x1D64
execute "digraphs vs " . 0x1D65
execute "digraphs xs " . 0x2093
execute "digraphs aS " . 0x1d43
execute "digraphs bS " . 0x1d47
execute "digraphs cS " . 0x1d9c
execute "digraphs dS " . 0x1d48
execute "digraphs eS " . 0x1d49
execute "digraphs fS " . 0x1da0
execute "digraphs gS " . 0x1d4d
execute "digraphs hS " . 0x02b0
execute "digraphs iS " . 0x2071
execute "digraphs jS " . 0x02b2
execute "digraphs kS " . 0x1d4f
execute "digraphs lS " . 0x02e1
execute "digraphs mS " . 0x1d50
execute "digraphs nS " . 0x207f
execute "digraphs oS " . 0x1d52
execute "digraphs pS " . 0x1d56
execute "digraphs rS " . 0x02b3
execute "digraphs sS " . 0x02e2
execute "digraphs tS " . 0x1d57
execute "digraphs uS " . 0x1d58
execute "digraphs vS " . 0x1d5b
execute "digraphs wS " . 0x02b7
execute "digraphs xS " . 0x02e3
execute "digraphs yS " . 0x02b8
execute "digraphs zS " . 0x1dbb
execute "digraphs AS " . 0x1D2C
execute "digraphs BS " . 0x1D2E
execute "digraphs DS " . 0x1D30
execute "digraphs ES " . 0x1D31
execute "digraphs GS " . 0x1D33
execute "digraphs HS " . 0x1D34
execute "digraphs IS " . 0x1D35
execute "digraphs JS " . 0x1D36
execute "digraphs KS " . 0x1D37
execute "digraphs LS " . 0x1D38
execute "digraphs MS " . 0x1D39
execute "digraphs NS " . 0x1D3A
execute "digraphs OS " . 0x1D3C
execute "digraphs PS " . 0x1D3E
execute "digraphs RS " . 0x1D3F
execute "digraphs TS " . 0x1D40
execute "digraphs US " . 0x1D41
execute "digraphs VS " . 0x2C7D
execute "digraphs WS " . 0x1D42
call plug#begin('~/.vim/plugged')
Plug 'Quramy/tsuquyomi'
Plug 'Chiel92/vim-autoformat'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'vim-syntastic/syntastic'
Plug 'panagosg7/vim-annotations'
Plug 'elmcast/elm-vim'
Plug 'fatih/vim-go'
Plug 'tpope/vim-fugitive'
Plug 'hashivim/vim-terraform'
Plug 'juliosueiras/vim-terraform-completion'
Plug 'andrewstuart/vim-kubernetes'
Plug 'tarekbecker/vim-yaml-formatter'
Plug 'aserebryakov/vim-todo-lists'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'psf/black'
call plug#end()
colorscheme maria
{
"languageserver": {
"haskell": {
"command": "haskell-language-server-wrapper",
"args": ["--lsp"],
"rootPatterns": ["*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml"],
"filetypes": ["haskell", "lhaskell", "hs", "lhs"]
},
"terraform": {
"command": "terraform-ls",
"args": ["serve"],
"filetypes": [
"terraform",
"tf"
],
"initializationOptions": {},
"settings": {}
}
},
"eslint.probe": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"html"
],
"eslint.options": {
"cache": true
},
"eslint.autoFixOnSave": true,
"eslint.fixOnSaveTimeout": 100000,
"tsserver.log": "verbose",
"cSpell.enabledLanguageIds": [
"markdown",
"plaintext",
"text"
],
"cSpell.userWords": ["Qualio", "medtech", "microfrontend"],
"diagnostic-languageserver.filetypes": {
"vim": "vint",
"email": "languagetool",
"markdown": ["write-good", "markdownlint"],
"sh": "shellcheck",
"yaml": ["yamllint"],
"cmake": ["cmake-lint", "cmakelint"]
}
}
" http://storiesofmaria.blogspot.com/2013/12/vim-green-black-color-scheme.html
" Thank you, Maria!
" Vim color file
" Maintainer: Maria
" Last Change: 2021 Dec
" This is a Vim dark color scheme with black background and green foreground colors
hi clear
if version > 580
" no guarantees for version 5.8 and below, but this makes it stop
" complaining
hi clear
if exists("syntax_on")
syntax reset
endif
endif
" Load the syntax highlighting defaults, if it's enabled.
if exists("syntax_on")
syntax reset
endif
let colors_name = "maria"
" highlight groups
" Set nice colors green foreground on dark background
highlight Normal guifg=#00FF00
highlight Normal guibg=#000000
hi Cursor guifg=black guibg=#004400 gui=none
hi ErrorMsg guifg=white guibg=red gui=none
hi VertSplit guifg=gray40 guibg=gray40 gui=none
hi Folded guifg=DarkSlateGray3 guibg=gray40 gui=none
hi FoldColumn guifg=tan guibg=#000000 gui=none
hi IncSearch guifg=#b0ffff guibg=#2050d0
hi LineNr guifg=burlywood3 gui=none
hi ModeMsg guifg=SkyBlue gui=none
hi MoreMsg guifg=SeaGreen gui=none
hi NonText guifg=cyan gui=none
hi Question guifg=springgreen gui=none
hi Search guifg=gray80 guibg=#445599 gui=none
hi SpecialKey guifg=cyan gui=none
hi StatusLine guifg=green guibg=black gui=bold
hi StatusLineNC guifg=gray guibg=gray40 gui=none
hi Title guifg=#ff4400 gui=none gui=bold
hi Visual guifg=gray17 guibg=tan1 gui=none
hi WarningMsg guifg=salmon gui=none
hi Pmenu guifg=#20AA10 guibg=#141832 gui=none
hi PmenuSel guifg=#445599 guibg=#415a3d
hi WildMenu guifg=gray guibg=gray17 gui=none
hi MatchParen guifg=cyan guibg=#6C6C6C gui=bold
hi DiffAdd guifg=black guibg=wheat1
hi DiffChange guifg=black guibg=skyblue1
hi DiffText guifg=black guibg=hotpink1 gui=none
hi DiffDelete guibg=gray45 guifg=black gui=none
" syntax highlighting groups
hi Comment guifg=darkcyan gui=none
" olive
hi Constant guifg=#808000 gui=none
hi Identifier guifg=#808000 gui=none
hi Function guifg=#82EF2A gui=none
hi Statement guifg=darkcyan gui=none
hi PreProc guifg=#82EF2A gui=none
hi Type guifg=darkgreen gui=none
hi Special guifg=#00AA00 gui=none
hi Ignore guifg=white gui=none
hi Todo guifg=darkgreen guibg=yellow2 gui=none
" color terminal definitions
hi SpecialKey ctermfg=red
hi NonText cterm=bold ctermfg=darkblue
hi Directory ctermfg=darkcyan
hi ErrorMsg cterm=bold ctermfg=7 ctermbg=1
hi IncSearch cterm=NONE ctermfg=yellow ctermbg=green
hi Search cterm=NONE ctermfg=white ctermbg=grey
hi MoreMsg ctermfg=darkgreen
hi ModeMsg cterm=NONE ctermfg=brown
hi LineNr ctermfg=3
hi Question ctermfg=green
hi StatusLine cterm=bold,reverse
hi StatusLineNC cterm=reverse
hi VertSplit cterm=reverse
hi Title ctermfg=5
hi Visual cterm=reverse
hi VisualNOS cterm=bold,underline
hi WarningMsg ctermfg=1
hi WildMenu ctermfg=0 ctermbg=3
hi Folded ctermfg=darkgrey ctermbg=NONE
hi FoldColumn ctermfg=darkgrey ctermbg=NONE
hi DiffAdd ctermbg=4
hi DiffChange ctermbg=5
hi DiffDelete cterm=bold ctermfg=4 ctermbg=6
hi DiffText cterm=bold ctermbg=1
hi Comment ctermfg=darkcyan
hi Constant ctermfg=brown
hi Special ctermfg=5
hi Identifier ctermfg=6
hi Statement ctermfg=3
hi PreProc ctermfg=5
hi Type ctermfg=2
hi Underlined cterm=underline ctermfg=5
hi Ignore ctermfg=darkgrey
hi Error cterm=bold ctermfg=7 ctermbg=1
" Coc
hi markdown guibg=#303030
hi link CocFloating markdown
hi FgCocErrorFloatBgCocFloating guifg=white
hi FgCocHintSignBgSignColumn guibg=#303030
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment