From 6397c20de553a43a825726c7bed3bf722ab48cd4 Mon Sep 17 00:00:00 2001 From: Alexander Poole Date: Tue, 29 Dec 2020 13:38:41 +0100 Subject: [PATCH] Add golang config and linting with ALE --- init.vim | 103 +++++++++++++++++++++++++++++++++++++++++++++++++- zshrc_profile | 7 ++++ 2 files changed, 109 insertions(+), 1 deletion(-) diff --git a/init.vim b/init.vim index 992f084..91ff45d 100644 --- a/init.vim +++ b/init.vim @@ -11,6 +11,11 @@ set autoindent " indent a new line the same amount as the line just set number " add line numbers set wildmode=longest,list " get bash-like tab completions set cc=80 " set an 80 column border for good coding style + +autocmd Filetype html setlocal ts=2 sw=2 expandtab +autocmd Filetype python setlocal ts=2 sw=2 expandtab +autocmd Filetype golang setlocal ts=4 sw=4 sts=0 noexpandtab + filetype plugin indent on " allows auto-indenting depending on file type syntax on " syntax highlighting @@ -64,10 +69,16 @@ Plug 'tpope/vim-fugitive' Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' +Plug 'dense-analysis/ale' + "These plugins gave me funcy behaviours might have to disable these when not ".js or .sol files "Plug 'pangloss/vim-javascript' -"Plug 'TovarishFin/vim-solidity' +Plug 'tomlion/vim-solidity' +Plug 'sohkai/syntastic-local-solhint' + +" Golang +Plug 'fatih/vim-go' call plug#end() " airline @@ -81,6 +92,14 @@ let NERDTreeShowHidden=1 " jedi-vim let g:jedi#completions_enabled = 0 let g:jedi#use_splits_not_buffers = "right" +let g:jedi#popup_on_dot = 0 +let g:jedi#goto_assignments_command = "g" +let g:jedi#goto_definitions_command = "d" +let g:jedi#documentation_command = "K" +let g:jedi#usages_command = "n" +let g:jedi#rename_command = "r" +let g:jedi#show_call_signatures = "0" +let g:jedi#smart_auto_mappings = 0 " deoplete inoremap pumvisible() ? "\" : "\" @@ -115,3 +134,85 @@ set clipboard=unnamedplus " set spellfile=file/in/version/control/en.utf-8.add set spell set spelllang=en_us + +" ale +let g:ale_linters = {} + +"***************************************************************************** +"" Custom configs +"***************************************************************************** + +" go +" vim-go +" run :GoBuild or :GoTestCompile based on the go file +function! s:build_go_files() + let l:file = expand('%') + if l:file =~# '^\f\+_test\.go$' + call go#test#Test(0, 1) + elseif l:file =~# '^\f\+\.go$' + call go#cmd#Build(0) + endif +endfunction + +let g:go_list_type = "quickfix" +let g:go_fmt_command = "goimports" +let g:go_fmt_fail_silently = 1 + +let g:go_highlight_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_build_constraints = 1 +let g:go_highlight_structs = 1 +let g:go_highlight_generate_tags = 1 +let g:go_highlight_space_tab_error = 0 +let g:go_highlight_array_whitespace_error = 0 +let g:go_highlight_trailing_whitespace_error = 0 +let g:go_highlight_extra_types = 1 + +autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 + +augroup completion_preview_close + autocmd! + if v:version > 703 || v:version == 703 && has('patch598') + autocmd CompleteDone * if !&previewwindow && &completeopt =~ 'preview' | silent! pclose | endif + endif +augroup END + +augroup go + + au! + au Filetype go command! -bang A call go#alternate#Switch(0, 'edit') + au Filetype go command! -bang AV call go#alternate#Switch(0, 'vsplit') + au Filetype go command! -bang AS call go#alternate#Switch(0, 'split') + au Filetype go command! -bang AT call go#alternate#Switch(0, 'tabe') + + au FileType go nmap dd (go-def-vertical) + au FileType go nmap dv (go-doc-vertical) + au FileType go nmap db (go-doc-browser) + + au FileType go nmap r (go-run) + au FileType go nmap t (go-test) + au FileType go nmap gt (go-coverage-toggle) + au FileType go nmap i (go-info) + au FileType go nmap l (go-metalinter) + au FileType go nmap :GoDecls + au FileType go nmap dr :GoDeclsDir + au FileType go imap :GoDecls + au FileType go imap dr :GoDeclsDir + au FileType go nmap rb :call build_go_files() + +augroup END + +" ale +:call extend(g:ale_linters, { + \"go": ['golint', 'go vet'], }) + +" python +" ale +:call extend(g:ale_linters, { + \'python': ['flake8'], }) + +"***************************************************************************** +"***************************************************************************** diff --git a/zshrc_profile b/zshrc_profile index 96ac49d..baade6f 100644 --- a/zshrc_profile +++ b/zshrc_profile @@ -23,3 +23,10 @@ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || pr source $HOME/.config/nvim/alias.sh source $HOME/.config/nvim/nvim_profile source $HOME/.local/venv/bin/activate + + +export PATH=$PATH:/usr/local/go/bin + +export GOPATH=$HOME/.local/golib +export PATH=$PATH:$GOPATH/bin +export GOPATH=$GOPATH:$HOME/Prog/go