Add go configuration to vim
added vim-go plugin and assorted mappings for tests, navigation, running and documenting go files
This commit is contained in:
parent
0187636e22
commit
9a1617b78a
1 changed files with 70 additions and 8 deletions
|
@ -62,6 +62,8 @@ Plug 'dyng/ctrlsf.vim'
|
||||||
Plug 'sheerun/vim-polyglot' " syntax plugins for almost every language
|
Plug 'sheerun/vim-polyglot' " syntax plugins for almost every language
|
||||||
Plug 'stephpy/vim-yaml'
|
Plug 'stephpy/vim-yaml'
|
||||||
Plug 'mhartington/nvim-typescript', {'for': 'typescript','do': './install.sh'}
|
Plug 'mhartington/nvim-typescript', {'for': 'typescript','do': './install.sh'}
|
||||||
|
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
|
||||||
|
Plug 'deoplete-plugins/deoplete-go', { 'do': 'make'}
|
||||||
|
|
||||||
" HTML Workflow
|
" HTML Workflow
|
||||||
Plug 'valloric/matchtagalways', { 'on': [] }
|
Plug 'valloric/matchtagalways', { 'on': [] }
|
||||||
|
@ -84,13 +86,15 @@ Plug 'lervag/wiki.vim'
|
||||||
|
|
||||||
" For async completion
|
" For async completion
|
||||||
Plug 'Shougo/deoplete.nvim', { 'on': [] } " automatic suggestions, can also perhaps be changed for newer plugs
|
Plug 'Shougo/deoplete.nvim', { 'on': [] } " automatic suggestions, can also perhaps be changed for newer plugs
|
||||||
|
Plug 'Shougo/echodoc.vim', { 'on': [] }
|
||||||
Plug 'w0rp/ale', { 'on': [] } " asynchronous linting - might be superseded by lsp or coc.nvim at some point
|
Plug 'w0rp/ale', { 'on': [] } " asynchronous linting - might be superseded by lsp or coc.nvim at some point
|
||||||
" lazy loading since they require a lot of startup time
|
" lazy loading since they require a lot of startup time
|
||||||
augroup load_ide_features
|
augroup load_ide_features
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd InsertEnter * call plug#load('ale', 'deoplete.nvim')
|
autocmd InsertEnter * call plug#load('ale', 'deoplete.nvim', 'echodoc.vim')
|
||||||
\| autocmd! load_ide_features
|
\| autocmd! load_ide_features
|
||||||
autocmd InsertEnter * call deoplete#enable()
|
autocmd InsertEnter * call deoplete#enable()
|
||||||
|
autocmd InsertEnter * call echodoc#enable()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Design
|
" Design
|
||||||
|
@ -99,9 +103,8 @@ Plug 'vim-airline/vim-airline-themes'
|
||||||
Plug 'edkolev/tmuxline.vim'
|
Plug 'edkolev/tmuxline.vim'
|
||||||
|
|
||||||
" Colorschemes
|
" Colorschemes
|
||||||
Plug 'Nequo/vim-allomancer'
|
|
||||||
Plug 'morhetz/gruvbox'
|
Plug 'morhetz/gruvbox'
|
||||||
Plug 'nightsense/snow'
|
Plug 'rakr/vim-one'
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
endif
|
endif
|
||||||
|
@ -212,6 +215,33 @@ endfunction
|
||||||
autocmd! User GoyoEnter nested call <SID>goyo_enter()
|
autocmd! User GoyoEnter nested call <SID>goyo_enter()
|
||||||
autocmd! User GoyoLeave nested call <SID>goyo_leave()
|
autocmd! User GoyoLeave nested call <SID>goyo_leave()
|
||||||
|
|
||||||
|
" PLUGIN: vim-go
|
||||||
|
" change the tabstops for go to use tabs and a width of 4
|
||||||
|
" this conforms with the gofmt expectations
|
||||||
|
au FileType go set noexpandtab
|
||||||
|
au FileType go set shiftwidth=4
|
||||||
|
au FileType go set softtabstop=4
|
||||||
|
au FileType go set tabstop=4
|
||||||
|
" enable all sorts of highlighting options for
|
||||||
|
" variables/functions/arguments...
|
||||||
|
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
|
||||||
|
" enable highlighting of other uses of the same variable
|
||||||
|
let g:go_auto_sameids = 1
|
||||||
|
" automatically import needed dependencies
|
||||||
|
" TODO do I need this? not doing it automatically does lead to more conscious
|
||||||
|
" decision making on imports
|
||||||
|
let g:go_fmt_command = "goimports"
|
||||||
|
" show type information for variables in the status line
|
||||||
|
let g:go_auto_type_info = 1
|
||||||
|
|
||||||
|
|
||||||
" PLUGIN: DEOPLETE
|
" PLUGIN: DEOPLETE
|
||||||
" enable deoplete at startup
|
" enable deoplete at startup
|
||||||
let g:deoplete#enable_at_startup = 0
|
let g:deoplete#enable_at_startup = 0
|
||||||
|
@ -222,15 +252,30 @@ let g:deoplete#enable_refresh_always = 1
|
||||||
let g:deoplete#max_abbr_width = 0
|
let g:deoplete#max_abbr_width = 0
|
||||||
let g:deoplete#max_menu_width = 0
|
let g:deoplete#max_menu_width = 0
|
||||||
let g:deoplete#omni#input_patterns = get(g:,'deoplete#omni#input_patterns',{})
|
let g:deoplete#omni#input_patterns = get(g:,'deoplete#omni#input_patterns',{})
|
||||||
|
" PLUGIN: ECHODOC
|
||||||
|
let g:echodoc#type="virtual"
|
||||||
|
set splitbelow
|
||||||
|
set completeopt+=menuone,noinsert,noselect
|
||||||
|
set completeopt-=preview
|
||||||
|
autocmd CompleteDone * pclose
|
||||||
|
|
||||||
" PLUGIN: ALE
|
" PLUGIN: ALE
|
||||||
|
" clearer Error and warning signs for the gutter
|
||||||
|
let g:ale_sign_error = '⤫'
|
||||||
|
let g:ale_sign_warning = '⚠'
|
||||||
|
" Enable integration with airline.
|
||||||
|
let g:airline#extensions#ale#enabled = 1
|
||||||
|
|
||||||
let g:ale_fix_on_save = 1
|
let g:ale_fix_on_save = 1
|
||||||
let g:ale_fixers = {
|
let g:ale_fixers = {
|
||||||
\'javascipt': ['eslint', 'prettier'],
|
\'javascipt': ['eslint', 'prettier'],
|
||||||
\'html': ['tidy','prettier'],
|
\'html': ['tidy','prettier'],
|
||||||
\'typescript': ['prettier','tslint'],
|
\'typescript': ['prettier','tslint'],
|
||||||
\'*': ['remove_trailing_lines', 'trim_whitespace'],
|
\'*': ['remove_trailing_lines', 'trim_whitespace'],
|
||||||
\}
|
\}
|
||||||
|
let g:ale_linters = {
|
||||||
|
\ 'go': ['gopls'],
|
||||||
|
\}
|
||||||
|
|
||||||
" PLUGIN: AIRLINE
|
" PLUGIN: AIRLINE
|
||||||
" PLUGIN: TMUXLINE
|
" PLUGIN: TMUXLINE
|
||||||
|
@ -368,6 +413,23 @@ nnoremap <leader><C-e> :NERDTreeVCS<CR>
|
||||||
" open current nerdtree with current file highlighted
|
" open current nerdtree with current file highlighted
|
||||||
nnoremap <leader>E :NERDTreeFind<CR>
|
nnoremap <leader>E :NERDTreeFind<CR>
|
||||||
|
|
||||||
|
" vim-go mappings - will only activate in go files
|
||||||
|
" most of this credit to https://hackernoon.com/my-neovim-setup-for-go-7f7b6e805876
|
||||||
|
" switch between test file and function
|
||||||
|
au Filetype go nnoremap <leader>ga <Plug>(go-alternate-edit)
|
||||||
|
" switch between test file and function - in a horizontal/vertical split
|
||||||
|
au Filetype go nnoremap <leader>gah <Plug>(go-alternate-split)
|
||||||
|
au Filetype go nnoremap <leader>gav <Plug>(go-alternate-vertical)
|
||||||
|
" run a test (but run it as short version, in case tests are tagged
|
||||||
|
" accordingly)
|
||||||
|
au FileType go nnoremap <F10> :GoTest -short<cr>
|
||||||
|
" show/hide code coverage of go file
|
||||||
|
au FileType go nnoremap <F9> :GoCoverageToggle -short<cr>
|
||||||
|
" To get the documentation of whatever you are hovering over press K (to go
|
||||||
|
" back C-t) -- this is enabled by default and needs no bind
|
||||||
|
" go to the definition of whatever you hover over
|
||||||
|
au FileType go nnoremap <F12> <Plug>(go-def)
|
||||||
|
|
||||||
" Call leaderf with <leader-f> (necessary to enable leaderf lazyloading)
|
" Call leaderf with <leader-f> (necessary to enable leaderf lazyloading)
|
||||||
nnoremap <leader>F :LeaderfFile<cr>
|
nnoremap <leader>F :LeaderfFile<cr>
|
||||||
nnoremap <leader>f :LeaderfBuffer<cr>
|
nnoremap <leader>f :LeaderfBuffer<cr>
|
||||||
|
|
Loading…
Reference in a new issue