From 2066baee05652d81d6991547dcbd23b4e0b7dd74 Mon Sep 17 00:00:00 2001 From: bretello Date: Thu, 19 Jan 2023 17:33:11 +0100 Subject: [PATCH] vim: linting cleanup --- vim/functions.vim | 35 +++++++++++++++++------------------ vim/plugins_config.vim | 40 ++++++++++++++++++++-------------------- vim/plugs.vim | 4 ++-- vim/shortcuts.vim | 8 ++++---- 4 files changed, 43 insertions(+), 44 deletions(-) diff --git a/vim/functions.vim b/vim/functions.vim index 0794e15..52891a9 100644 --- a/vim/functions.vim +++ b/vim/functions.vim @@ -10,8 +10,8 @@ function! WinZoomToggle() abort wincmd | let w:WinZoomIsZoomed = 1 elseif w:WinZoomIsZoomed == 1 - execute "resize " . w:WinZoomOldHeight - execute "vertical resize " . w:WinZoomOldWidth + execute 'resize ' . w:WinZoomOldHeight + execute 'vertical resize ' . w:WinZoomOldWidth let w:WinZoomIsZoomed = 0 endif endfunction @@ -42,8 +42,8 @@ endfunction " Don't close window, when deleting a buffer command! Bclose call BufcloseCloseIt() function! BufcloseCloseIt() - let l:currentBufNum = bufnr("%") - let l:alternateBufNum = bufnr("#") + let l:currentBufNum = bufnr('%') + let l:alternateBufNum = bufnr('#') if buflisted(l:alternateBufNum) buffer # @@ -51,35 +51,35 @@ function! BufcloseCloseIt() bnext endif - if bufnr("%") == l:currentBufNum + if bufnr('%') == l:currentBufNum new endif if buflisted(l:currentBufNum) - execute("bdelete! ".l:currentBufNum) + execute('bdelete! '.l:currentBufNum) endif endfunction function! CmdLine(str) - call feedkeys(":" . a:str) + call feedkeys(':' . a:str) endfunction " Call Git show on the selected text (must be a git ref) function! GitShowVisual() range - execute "Git show " . @* + execute 'Git show ' . @* endfunction function! VisualSelection(direction, extra_filter) range let l:saved_reg = @" - execute "normal! vgvy" + execute 'normal! vgvy' - let l:pattern = escape(@", "\\/.*'$^~[]") - let l:pattern = substitute(l:pattern, "\n$", "", "") + let l:pattern = escape(@', "\\/.*'$^~[]") + let l:pattern = substitute(l:pattern, '\n$', '', '') - if a:direction == 'ack' + if a:direction ==# 'ack' call CmdLine("Ack '" . l:pattern . "' ") - elseif a:direction == 'replace' - call CmdLine("%s" . '/'. l:pattern . '/') + elseif a:direction ==# 'replace' + call CmdLine('%s' . '/'. l:pattern . '/') endif let @/ = l:pattern @@ -100,8 +100,8 @@ function! Redir(cmd, rng, start, end) execute win . 'windo close' endif endfor - if a:cmd =~ '^!' - let cmd = a:cmd =~' %' + if a:cmd =~? '^!' + let cmd = a:cmd =~?' %' \ ? matchstr(substitute(a:cmd, ' %', ' ' . expand('%:p'), ''), '^!\zs.*') \ : matchstr(a:cmd, '^!\zs.*') if a:rng == 0 @@ -109,7 +109,7 @@ function! Redir(cmd, rng, start, end) else let joined_lines = join(getline(a:start, a:end), '\n') let cleaned_lines = substitute(shellescape(joined_lines), "'\\\\''", "\\\\'", 'g') - let output = systemlist(cmd . " <<< $" . cleaned_lines) + let output = systemlist(cmd . ' <<< $' . cleaned_lines) endif else redir => output @@ -149,4 +149,3 @@ function! Cmd(cmd) endfunction command! -nargs=1 -complete=shellcmd Cmd silent call Cmd() - diff --git a/vim/plugins_config.vim b/vim/plugins_config.vim index 842c95c..aa39bf6 100644 --- a/vim/plugins_config.vim +++ b/vim/plugins_config.vim @@ -17,37 +17,37 @@ let g:ale_fixers = { \ 'java': ['eclipselsp'], \ 'yaml': ['prettier'], \ 'python': ['black', 'isort'], - \ 'go': ['gofmt', "goimports"], + \ 'go': ['gofmt', 'goimports'], \ 'rust': ['rustfmt'], \ 'sql': ['pgformatter'], - \ "javascript": ["prettier", "eslint"], - \ "vue": ["prettier", "eslint"] + \ 'javascript': ['prettier', 'eslint'], + \ 'vue': ['prettier', 'eslint'] \} let g:ale_fixers_aliases = {'vue': ['vue', 'javascript']} let g:ale_popup_menu_enabled =1 -let g:ale_python_bandit_options = "-c banditrc" -let g:ale_python_pylint_options = "-j0 --disable=W0511" -let g:ale_python_mypy_options = "--ignore-missing-imports" +let g:ale_python_bandit_options = '-c banditrc' +let g:ale_python_pylint_options = '-j0 --disable=W0511' +let g:ale_python_mypy_options = '--ignore-missing-imports' " let g:ale_cpp_clang_options = '-std=c++17 -Wall -Wpedantic' " let g:ale_cpp_gcc_options = '-std=c++17 -Wall -Wpedantic' let g:ale_rust_cargo_use_clippy = 1 let g:ale_linters = { - \ 'bash': ['bash-language-server', 'bashlint', "shellcheck"], - \ 'dockerfile': ["hadolint"], - \ 'zsh': ['bashlint', "shellcheck"], + \ 'bash': ['bash-language-server', 'bashlint', 'shellcheck'], + \ 'dockerfile': ['hadolint'], + \ 'zsh': ['bashlint', 'shellcheck'], \ 'c': ['clangd'], \ 'cpp': ['clangd'], - \ 'python': ['pylsp', 'pylint', 'bandit', "mypy", "flake8"], + \ 'python': ['pylsp', 'pylint', 'bandit', 'mypy', 'flake8'], \ 'go': ['gopls', 'gobuild'], \ 'rust': ['analyzer'], \ 'yaml': ['yamllint'], - \ 'javascript': ["yarn lint", "eslint", "vls"] + \ 'javascript': ['yarn lint', 'eslint', 'vls'] \} let g:ale_linter_aliases = {'vue': ['vue', 'javascript']} -let g:ale_yaml_yamllint_options = "--config .editorconfig" +let g:ale_yaml_yamllint_options = '--config .editorconfig' let g:ale_open_list = 0 let g:ale_keep_list_window_open = 1 @@ -66,9 +66,9 @@ let g:ale_lsp_suggestions = 1 let g:ale_rename_tsserver_find_in_comment = 1 let g:ale_sign_priority = 99 -let g:ale_sign_error = "xx" -let g:ale_sign_warning = ">>" -let g:ale_sign_info = "--" +let g:ale_sign_error = 'xx' +let g:ale_sign_warning = '>>' +let g:ale_sign_info = '--' "let g:ale_sign_style_error = "let g:ale_sign_style_warning = highlight link ALEVirtualTextError ALEError @@ -190,10 +190,10 @@ let g:gutentags_ctags_extra_args = ['--tag-relative=always', ] let NERDTreeIgnore=['__pycache__'] " ultisnips -let g:UltiSnipsExpandTrigger="" -let g:UltiSnipsJumpForwardTrigger="" -let g:UltiSnipsJumpBackwardTrigger="" -let g:UltiSnipsEditSplit="context" +let g:UltiSnipsExpandTrigger='' +let g:UltiSnipsJumpForwardTrigger='' +let g:UltiSnipsJumpBackwardTrigger='' +let g:UltiSnipsEditSplit='context' "" Fzf let g:fzf_layout = { 'window': { 'width': 1, 'height': 0.9 } } @@ -217,5 +217,5 @@ autocmd FileType fzf set laststatus=0 noshowmode noruler \| autocmd BufLeave set laststatus=2 showmode ruler -let g:goyo_width="85%" +let g:goyo_width='85%' let g:goyo_linenr=1 diff --git a/vim/plugs.vim b/vim/plugs.vim index fb34658..3cbf263 100644 --- a/vim/plugs.vim +++ b/vim/plugs.vim @@ -14,7 +14,7 @@ Plug 'https://github.com/morhetz/gruvbox' "Plug 'kristijanhusak/vim-hybrid-material' "Plug 'https://github.com/rafi/awesome-vim-colorschemes' -" Csv files 🤦" +" Csv files 🤦 Plug 'https://github.com/mechatroner/rainbow_csv', { 'for': 'csv' } " Asynchronous Linting Engine @@ -50,7 +50,7 @@ Plug 'junegunn/fzf.vim' Plug 'https://github.com/ludovicchabant/vim-gutentags.git' " snippets -if has("python3") +if has('python3') Plug 'https://github.com/SirVer/ultisnips' Plug 'https://github.com/honza/vim-snippets' endif diff --git a/vim/shortcuts.vim b/vim/shortcuts.vim index a47dade..3534b73 100644 --- a/vim/shortcuts.vim +++ b/vim/shortcuts.vim @@ -1,5 +1,5 @@ """" Leader shortcuts -let mapleader = "," +let mapleader = ',' " also use space as leader map @@ -122,12 +122,12 @@ nmap zz :Goyo nmap :TagbarToggle ""Misc stuff -if g:uname == "Darwin" +if g:uname ==? 'Darwin' "" Mac specific stuff -elseif g:uname == "Linux" +elseif g:uname ==? 'Linux' "" Linux specific stuff function! s:WaylandYank() - if v:event['regname'] == '+' || (v:event['regname'] == 'w' && s:plus_to_w) + if v:event['regname'] ==# '+' || (v:event['regname'] ==# 'w' && s:plus_to_w) call system('wl-copy', getreg(v:event['regname'])) endif endfunction