1 set number " Show: Line numbers
2 set cursorline " Hilight current curser line
3 set noshowmode " Hide: -- INSERT --
4 set listchars=tab:»\ ,extends:›,precedes:‹,nbsp:·,space:·,trail:·
5 set list " Show white space
10 set colorcolumn=80,120
12 " set clipboard+=unnamedplus
15 set undodir=~/.config/nvim/undo
18 autocmd BufEnter * if &filetype != 'nerdtree' && &filetype != 'help' | set conceallevel=0 | endif
24 set spell spelllang=en_us,de_de
27 highlight clear CocHighlightText
28 highlight CocHighlightText cterm=underline gui=underline
29 set hlsearch " Highlight search results.
30 set ignorecase " Make searching case insensitive
31 set smartcase " ... unless the query has capital letters.
32 set incsearch " Incremental search.
33 set gdefault " Use 'g' flag by default with :s/foo/bar/.
34 set magic " Use 'magic' patterns (extended regular expressions).
35 set nofoldenable " Never fold (by defauld, override for sim languages)
38 exec 'set wildignore=' . join([
53 if exists('##CompleteChanged') && exists('*nvim_open_win')
60 let maplocalleader = "-"
63 nnoremap <silent><Tab> :tabnext<CR>
64 nnoremap <silent><S-Tab> :tabprevious<CR>
67 nnoremap <silent>m<Tab> :tabm +1<CR>
68 nnoremap <silent>m<S-Tab> :tabm -1<CR>
70 " nnoremap <silent><C-t> :tabnew<CR>
71 nnoremap <silent><C-q> :quit<CR>
73 nnoremap <silent><C-t> :split term://zsh<CR>i
78 " Use tab for trigger completion with characters ahead and navigate.
79 " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
80 " other plugin before putting this into your config.
81 inoremap <silent><expr> <TAB>
82 \ pumvisible() ? "\<C-n>" :
83 \ <SID>check_back_space() ? "\<TAB>" :
85 inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
87 function! s:check_back_space() abort
88 let col = col('.') - 1
89 return !col || getline('.')[col - 1] =~# '\s'
92 " Use <c-space> to trigger completion.
93 inoremap <silent><expr> <c-space> coc#refresh()
95 " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
96 " position. Coc only does snippet and additional edit on confirm.
97 " <cr> could be remapped by other vim plugin, try `:verbose imap <CR>`.
98 if exists('*complete_info')
99 inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
101 inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
104 " Use `[g` and `]g` to navigate diagnostics
105 nmap <silent> [g <Plug>(coc-diagnostic-prev)
106 nmap <silent> ]g <Plug>(coc-diagnostic-next)
108 " GoTo code navigation.
109 nmap <silent> gd <Plug>(coc-definition)
110 nmap <silent> gy <Plug>(coc-type-definition)
111 nmap <silent> gi <Plug>(coc-implementation)
112 nmap <silent> gr <Plug>(coc-references)
114 " Use K to show documentation in preview window.
115 nnoremap <silent> K :call <SID>show_documentation()<CR>
117 function! s:show_documentation()
118 if (index(['vim','help'], &filetype) >= 0)
119 execute 'h '.expand('<cword>')
121 call CocAction('doHover')
125 " Highlight the symbol and its references when holding the cursor.
126 autocmd CursorHold * silent call CocActionAsync('highlight')
131 " Setup formatexpr specified filetype(s).
132 autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
133 " Update signature help on jump placeholder.
134 autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
137 " Applying codeAction to the selected region.
138 " Example: `<leader>aap` for current paragraph
139 xmap <leader>a <Plug>(coc-codeaction-selected)
140 nmap <leader>a <Plug>(coc-codeaction-selected)
142 " Remap keys for applying codeAction to the current line.
143 nmap <leader>ac <Plug>(coc-codeaction-line)
144 " Apply AutoFix to problem on the current line.
145 nmap <leader>qf <Plug>(coc-fix-current)
147 " Introduce function text object
148 " NOTE: Requires 'textDocument.documentSymbol' support from the language server.
149 xmap if <Plug>(coc-funcobj-i)
150 xmap af <Plug>(coc-funcobj-a)
151 omap if <Plug>(coc-funcobj-i)
152 omap af <Plug>(coc-funcobj-a)
154 " Use <TAB> for selections ranges.
155 " NOTE: Requires 'textDocument/selectionRange' support from the language server.
156 " coc-tsserver, coc-python are the examples of servers that support it.
157 " nmap <silent> <TAB> <Plug>(coc-range-select)
158 xmap <silent> <TAB> <Plug>(coc-range-select)
160 " Add `:Format` command to format current buffer.
161 command! -nargs=0 Format :call CocAction('format')
163 " Add `:Fold` command to fold current buffer.
164 command! -nargs=? Fold :call CocAction('fold', <f-args>)
166 " Add `:OR` command for organize imports of the current buffer.
167 command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
169 " Mappings using CoCList:
171 nmap <leader>rn <Plug>(coc-rename)
173 " Formatting selected code.
174 xmap <leader>f <Plug>(coc-format-selected)
175 nmap <leader>f <Plug>(coc-format-selected)
177 nnoremap <leader>d :CocFzfList diagnostics --current-buf<cr>
178 nnoremap <leader>c :CocFzfList commands<cr>
179 nnoremap <leader>o :CocFzfList outline<cr>
180 nnoremap <leader>s :CocFzfList symbols<cr>
184 " nnoremap <leader>j :<C-u>CocNext<CR>
185 " nnoremap <leader>k :<C-u>CocPrev<CR>
188 autocmd BufWritePre *.go :call CocAction('organizeImport')
190 autocmd FileType go nmap <buffer> gta :call CocAction('runCommand', 'go.tags.add')<cr>
191 autocmd FileType go nmap <buffer> gtl :call CocAction('runCommand', 'go.tags.add.line')<cr>
192 autocmd FileType go nmap <buffer> gtr :call CocAction('runCommand', 'go.tags.remove')<cr>
193 autocmd FileType go nmap <buffer> gtj :call CocAction('runCommand', 'go.tags.add', 'json')<cr>
194 autocmd FileType go nmap <buffer> gty :call CocAction('runCommand', 'go.tags.add', 'yaml')<cr>
195 autocmd FileType go nmap <buffer> gtx :call CocAction('runCommand', 'go.tags.clear')<cr>