257 lines
8.1 KiB
VimL
257 lines
8.1 KiB
VimL
set nocompatible
|
|
|
|
so ~/.config/nvim/plugins.vim
|
|
"so ~/.config/nvim/word_processing.vim
|
|
|
|
" --Plugin Configurations
|
|
let g:go_metalinter_enabled = [
|
|
\'bodyclose', 'deadcode', 'errcheck', 'goconst', 'gocritic', 'gocyclo', 'golint', 'gomnd', 'gosimple', 'govet',
|
|
\'ineffassign', 'interfacer', 'lll', 'misspell', 'prealloc', 'staticcheck', 'structcheck', 'typecheck', 'unconvert',
|
|
\'unparam', 'unused', 'varcheck'
|
|
\]
|
|
let g:go_highlight_build_constraints = 1
|
|
let g:go_highlight_extra_types = 1
|
|
let g:go_highlight_fields = 1
|
|
let g:go_highlight_functions = 1
|
|
let g:go_highlight_methods = 1
|
|
let g:go_highlight_operators = 1
|
|
let g:go_highlight_structs = 1
|
|
let g:go_highlight_types = 1
|
|
let g:go_def_mapping_enabled = 0
|
|
let g:airline#extensions#tabline#enabled = 1
|
|
let g:airline_powerline_fonts = 1
|
|
|
|
set title "Update title of the terminal
|
|
set number "Display line numbers
|
|
set relativenumber
|
|
set ruler "Display cursor position
|
|
set wrap "Wrap lines when they are long
|
|
set scrolloff=3 "Display 3 lines around the cursor when scrolling
|
|
set clipboard+=unnamedplus " use system clipboard
|
|
set guicursor+=a:blinkon0
|
|
filetype on
|
|
filetype plugin on
|
|
filetype plugin indent on
|
|
filetype indent on
|
|
|
|
"--Search
|
|
set ignorecase "Case insensitive search
|
|
set smartcase "Just in case I still want case sensitive search
|
|
"Case sensitive when there's upper case
|
|
set incsearch "Incremental search
|
|
set hlsearch "Highlight search results
|
|
noremap // :nohls<RETURN>
|
|
|
|
"--Beep
|
|
set noerrorbells "Vim is annoying
|
|
|
|
set shiftwidth=4
|
|
set tabstop=4
|
|
set scrolloff=10
|
|
set softtabstop=0
|
|
|
|
set updatetime=100 "Vim gitgutter
|
|
|
|
"--My ColorScheme
|
|
set background=dark
|
|
set termguicolors
|
|
colorscheme challenger_deep
|
|
hi Comment guifg=#f4b0f0 ctermfg=102
|
|
hi Normal guibg=#00000ee
|
|
|
|
let mapleader=","
|
|
noremap <leader>1 1gt
|
|
noremap <leader>2 2gt
|
|
noremap <leader>3 3gt
|
|
noremap <leader>4 4gt
|
|
noremap <leader>5 5gt
|
|
noremap <leader>6 6gt
|
|
noremap <leader>7 7gt
|
|
noremap <leader>8 8gt
|
|
noremap <leader>9 9gt
|
|
noremap <leader>0 0gt
|
|
inoremap jj <Esc>
|
|
|
|
noremap <leader>w :e<SPACE>
|
|
noremap <leader>e :Files<CR>
|
|
noremap <leader>b :Buffers<CR>
|
|
nnoremap <C-k> :bprev<CR>
|
|
nnoremap <C-j> :bnext<CR>
|
|
"nnoremap <leader>d :bd<CR>
|
|
nnoremap <leader>d :bp<cr>:bd #<cr>
|
|
" (f)ind in file, (g)rep, (h)elp
|
|
noremap <leader>f :tabnew<CR>:Find<CR>
|
|
noremap <leader>g :vimgrep // **/*.<C-R>=expand('%:e')<CR><C-Left><C-Left><Right>
|
|
noremap <leader>h :help<SPACE>
|
|
|
|
noremap <leader>n :cn<CR>
|
|
noremap <leader>p :cp<CR>
|
|
noremap <leader>so :so ~/.config/nvim/init.vim<CR>
|
|
|
|
autocmd BufNewFile,BufRead .*config,*.config,config
|
|
\ setlocal filetype=gitconfig
|
|
autocmd BufNewFile,BufRead *.bolt
|
|
\ setlocal filetype=typescript
|
|
autocmd BufNewFile,BufRead *.cql
|
|
\ setlocal filetype=cql
|
|
autocmd BufNewFile,BufRead *.gradle,*.groovy
|
|
\ setlocal filetype=groovy
|
|
autocmd BufNewFile,BufRead *.osgjs,*.osgjs.gz
|
|
\ setlocal filetype=json
|
|
autocmd BufNewFile,BufRead *.go.tpl,*.peg,*.qtpl
|
|
\ setlocal syntax=go
|
|
autocmd BufNewFile,BufRead *.gunk
|
|
\ setlocal filetype=gunk syntax=go
|
|
autocmd BufNewFile,BufRead *.gltf
|
|
\ setlocal filetype=gltf syntax=json
|
|
autocmd BufNewFile,BufRead *.frag
|
|
\ setlocal filetype=glsl syntax=glsl
|
|
|
|
" Coc.NVIM
|
|
" Set internal encoding of vim, not needed on neovim, since coc.nvim using some
|
|
" unicode characters in the file autoload/float.vim
|
|
set encoding=utf-8
|
|
|
|
" TextEdit might fail if hidden is not set.
|
|
set hidden
|
|
|
|
" Give more space for displaying messages.
|
|
set cmdheight=2
|
|
|
|
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
|
|
" delays and poor user experience.
|
|
set updatetime=300
|
|
|
|
" Don't pass messages to |ins-completion-menu|.
|
|
set shortmess+=c
|
|
|
|
" Always show the signcolumn, otherwise it would shift the text each time
|
|
" diagnostics appear/become resolved.
|
|
if has("patch-8.1.1564")
|
|
" Recently vim can merge signcolumn and number column into one
|
|
set signcolumn=number
|
|
else
|
|
set signcolumn=yes
|
|
endif
|
|
|
|
" vim sideways
|
|
nnoremap <c-h> :SidewaysLeft<cr>
|
|
nnoremap <c-l> :SidewaysRight<cr>
|
|
|
|
" Use <c-space> to trigger completion.
|
|
if has('nvim')
|
|
inoremap <silent><expr> <c-space> coc#refresh()
|
|
else
|
|
inoremap <silent><expr> <c-@> coc#refresh()
|
|
endif
|
|
|
|
" Make <CR> auto-select the first completion item and notify coc.nvim to
|
|
" format on enter, <cr> could be remapped by other vim plugin
|
|
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
|
|
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
|
" 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 <SID>show_documentation()<CR>
|
|
|
|
function! s:show_documentation()
|
|
if (index(['vim','help'], &filetype) >= 0)
|
|
execute 'h '.expand('<cword>')
|
|
elseif (coc#rpc#ready())
|
|
call CocActionAsync('doHover')
|
|
else
|
|
execute '!' . &keywordprg . " " . expand('<cword>')
|
|
endif
|
|
endfunction
|
|
|
|
function! s:doHover()
|
|
if coc#rpc#ready()
|
|
let diagnostics = CocAction('diagnosticList')
|
|
if empty(diagnostics)
|
|
call CocActionAsync('doHover')
|
|
return
|
|
endif
|
|
let file = expand('%:p')
|
|
let lnum = line('.')
|
|
let cnum = col('.')
|
|
for v in diagnostics
|
|
if v['file'] != file
|
|
\ || lnum != v['lnum']
|
|
\ || cnum < v['location']['range']['start']['character']
|
|
\ || cnum > v['location']['range']['end']['character']
|
|
call CocActionAsync('doHover')
|
|
return
|
|
endif
|
|
endfor
|
|
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)
|
|
|
|
augroup mygroup
|
|
autocmd!
|
|
" Setup formatexpr specified filetype(s).
|
|
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
|
|
" Update signature help on jump placeholder.
|
|
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
|
augroup end
|
|
|
|
" 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
|
|
|
|
" Add `:Format` command to format current buffer.
|
|
command! -nargs=0 Format :call CocAction('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 CocAction('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','')}
|
|
let g:airline_theme='bubblegum'
|
|
|
|
" 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.
|