diff --git a/config/vim/.gitignore b/config/vim/.gitignore index ed0e3f9..6a0b25f 100644 --- a/config/vim/.gitignore +++ b/config/vim/.gitignore @@ -1 +1,3 @@ plugged +extra/* +!extra/.gitkeep diff --git a/config/vim/after/autocmd.vim b/config/vim/after/autocmd.vim new file mode 100644 index 0000000..8381a89 --- /dev/null +++ b/config/vim/after/autocmd.vim @@ -0,0 +1,64 @@ +"" The PC is fast enough, do syntax highlight +"" syncing from start 6nless 200 lines +augroup vimrc-sync-fromstart + autocmd! + autocmd BufEnter * :syntax sync maxlines=600 +augroup END + +"" txt +augroup vimrc-wrapping + autocmd! + autocmd BufRead,BufNewFile *.txt call s:setupWrapping() +augroup END + +"" make/cmake +augroup vimrc-make-cmake + autocmd! + autocmd FileType make setlocal noexpandtab + autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake +augroup END + +set autoread + +""" Create/get autocommand group +function! s:CreateAugroup(name) abort + execute 'augroup' a:name + autocmd! + augroup END +endfunction + +" Highlight on yank +" See `:help vim.highlight.on_yank()` +call s:CreateAugroup('YankHighlight') +autocmd YankHighlight TextYankPost * silent! lua vim.highlight.on_yank() + +" Set the numberwidth to the maximum line number. +" Fixes the issue where the line numbers jump +" around when moving between lines with relative line numbers enabled. +call s:CreateAugroup('AdjustNumberWidth') +autocmd AdjustNumberWidth BufEnter,BufWinEnter,TabEnter * + \ let max_line_count = line('$') | + \ if max_line_count > 99 | + \ let &numberwidth = strlen(string(max_line_count)) + 1 + \ endif + +" Windows to close with "q" +call s:CreateAugroup('close_with_q') +autocmd close_with_q FileType checkhealth,dbout,gitsigns.blame,grug-far,help, + \ lspinfo,man,neotest-output,neotest-output-panel,neotest-summary,notify, + \ qf,spectre_panel,startuptime,tsplayground + \ setlocal buflisted=false | + \ nnoremap q :close + +" Make it easier to close man-files when opened inline +call s:CreateAugroup('man_unlisted') +autocmd man_unlisted FileType man setlocal buflisted=false + +" Wrap and check for spell in text filetypes +call s:CreateAugroup('wrap_spell') +autocmd wrap_spell FileType text,plaintex,typst,gitcommit,markdown,asciidoc,rst,tex + \ setlocal wrap spell + +" Fix conceallevel for json files +call s:CreateAugroup('json_conceal') +autocmd json_conceal FileType json,jsonc,json5 setlocal conceallevel=0 diff --git a/config/vim/after/colors.vim b/config/vim/after/colors.vim new file mode 100644 index 0000000..b77141c --- /dev/null +++ b/config/vim/after/colors.vim @@ -0,0 +1,26 @@ +function! ChangeColorScheme(channel, msg) + let time = trim(a:msg) + if time ==# "Dark" + set background="dark" + else + set background="light" + endif +endfunction + +function! CheckStatus(timer) + if executable("defaults") + let job = job_start( + \ ["defaults", "read", "-g", "AppleInterfaceStyle"], + \ {"out_cb": "ChangeColorScheme"} + \ ) + else + set background="dark" + endif +endfunction + +function! AutoDarkModeSetup() + let timer = timer_start(3000, 'CheckStatus', {'repeat': -1}) + call CheckStatus(timer) " Initial call to setup the theme +endfunction + +call AutoDarkModeSetup() diff --git a/config/vim/after/mappings.vim b/config/vim/after/mappings.vim new file mode 100644 index 0000000..62d52e9 --- /dev/null +++ b/config/vim/after/mappings.vim @@ -0,0 +1,113 @@ +"***************************************************************************** +"" Abbreviations +"***************************************************************************** +"" no one is really happy until you have this shortcuts +cnoreabbrev W! w! " force write +cnoreabbrev Q! q! " force quit +cnoreabbrev Qall! qall! " force quit all +cnoreabbrev Wq wq " write and quit +cnoreabbrev Wa wa " write all +cnoreabbrev wQ wq " write and quit +cnoreabbrev WQ wq " write and quit +cnoreabbrev W w " write +cnoreabbrev Q q " quit +cnoreabbrev Qall qall " quit all + +"***************************************************************************** +"" Mappings +"***************************************************************************** + +noremap :w " save buffer + +" Split +noremap h :split " horizontal split +noremap v :vsplit " vertical split + +" Git +noremap ga :Gwrite +noremap gc :Git commit --verbose +noremap gsh :Git push +noremap gll :Git pull +noremap gs :Git +noremap gb :Git blame +noremap gd :Gvdiffsplit +noremap gr :GRemove + +" session management +nnoremap so :OpenSession +nnoremap ss :SaveSession +nnoremap sd :DeleteSession +nnoremap sc :CloseSession + +" Tabs +nnoremap gt " next tab +nnoremap gT " previous tab +nnoremap :tabnew " new tab + +nnoremap . :lcd %:p:h " set working directory to the current file + +" Opens an edit command with the path of the currently +" edited file filled in +noremap e :e =expand("%:p:h") . "/" + +" Opens a tab edit command with the path of the currently +" edited file filled +noremap r :tabe =expand("%:p:h") . "/" + +" fzf.vim +let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'vendor/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null" + +cnoremap =expand("%:p:h") . "/" +nnoremap b :Buffers +nnoremap e :FZF -m +" Recovery commands from history through FZF +nmap y :History: + +" Tagbar +nmap :TagbarToggle " open tagbar +let g:tagbar_autofocus = 1 + +" Disable visualbell +set noerrorbells visualbell t_vb= +if has('autocmd') + autocmd GUIEnter * set visualbell t_vb= +endif + +"" Copy/Paste/Cut +if has('unnamedplus') + set clipboard=unnamed,unnamedplus +endif + +noremap YY "+y " copy line +noremap p "+gP " paste +noremap XX "+x " cut + +if has('macunix') + " pbcopy for OSX copy/paste + vmap :!pbcopy " copy + vmap :w !pbcopy " cut + vmap :!pbpaste " paste +endif + +"" Buffer nav +noremap z :bp " previous buffer +noremap x :bn " next buffer +noremap bq :bp " previous buffer +noremap bw :bn " next buffer +noremap bd :bd " close buffer + + +"" Switching windows +noremap j " move to window below +noremap k " move to window above +noremap l " move to window right +noremap h " move to window left + +vmap < >gv " move visual block right, keep selection +vnoremap J :m '>+1gv=gv " move visual block down, keep selection +vnoremap K :m '<-2gv=gv " move visual block up, keep selection + +nnoremap o :.GBrowse " open current line on GitHub +nnoremap sh :terminal " open a new terminal +nnoremap :noh " clean search diff --git a/config/vim/after/settings.vim b/config/vim/after/settings.vim new file mode 100644 index 0000000..b021c01 --- /dev/null +++ b/config/vim/after/settings.vim @@ -0,0 +1,84 @@ +let mapleader=' ' " Map leader to +filetype off " disable filetype detection (but re-enable later, see below) + +" find matching tags in html/xml documents using matchit +filetype plugin on +packadd! matchit +" disable super buggy netrw +let g:loaded_netrw=1 +let g:netrw_loaded_netrwPlugin=1 +" show JSDoc highlight colors +let g:javascript_plugin_jsdoc=1 + +set backspace=indent,eol,start " Backspace behavior +set cindent " Use 'C' style program indenting +set cursorline " Highlight current line +set encoding=utf-8 " UTF-8 +set expandtab " Use spaces instead of tabs +set fileformats=unix,dos,mac " File formats +set foldmethod=indent " Fold based on indent +set foldlevel=99 " Open all folds +set guioptions=egmrti " GUI options +set hidden " Enable hidden buffers +set ignorecase " Always case-insensitive +set incsearch " Searches for strings incrementally +set laststatus=2 " Always show statusline (even with only single window) +set linespace=3 " Set line spacing +set list " Show invisible characters +set listchars=tab:⌴\ ,trail:◼,nbsp:•,extends:…,precedes:… " Invisible characters +set modeline " Enable modelines +set modelines=3 " Number of lines to check for modelines +set mouse=a " Enable mouse support +set mousemodel=popup " Enable mouse support +set nobackup " Disable backup files +set nocompatible " disable compatibility mode with vi +set nowritebackup " Disable backup files +set number " Show line numbers +set relativenumber " Show relative line numbers +set ruler " Show row and column ruler information +set scrolloff=8 " Minimum number of lines to keep above and below the cursor +set shiftwidth=4 " Number of auto-indent spaces +set shortmess+=A " Don't show autocommand messages +set shortmess+=F " Avoid showing the "file-info" message +set shortmess+=I " Don't show intro message +set shortmess+=O " Avoid showing the "file-read" message +set shortmess+=O " Don't show overlength messages +set shortmess+=T " Don't show title messages +set shortmess+=W " Don't show "written" messages +set shortmess+=a " Avoid showing the "ATTENTION" message +set shortmess+=c " Avoid showing the "ins-completion-menu" message +set shortmess+=c " Don't pass messages to |ins-completion-menu| +set shortmess+=o " Avoid showing the "overlength" message +set shortmess+=t " Avoid showing the "trailing whitespace" message +set showcmd " Show command in status line +set showmatch " Highlight matching brace +set signcolumn=yes " Show sign column +set smartcase " Enable smart-case search +set smartindent " Enable smart-indent +set smarttab " Enable smart-tabs +set softtabstop=4 " Number of spaces per Tab +set spelllang=fi,en " Set the spell language +set spellsuggest=double " Suggest the first word when spell checking +set t_Co=256 " 256 colors +set termguicolors " Enable 24-bit RGB color in the terminal +set timeoutlen=500 " By default timeoutlen=1000 (ms) +set ttimeoutlen=0 " By default ttimeoutlen=-1 (ms) +set undolevels=1000 " Number of undo levels +set visualbell " Use visual bell (no beeping) +set wildmenu " Enable wildmenu +set wildmode=longest,list:longest " Command-line completion mode +set wrap " Wrap lines +set wrapscan " Searches wrap around the end of the file + +" Ignore these files in wildmenu +set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__,vendor + +colorscheme iceberg " Set the color scheme +filetype plugin indent on " enable filetype detection, plugins and indenting + +" Set the shell +if exists('$SHELL') + set shell=$SHELL +else + set shell=/bin/sh +endif diff --git a/config/vim/after/ui.vim b/config/vim/after/ui.vim new file mode 100644 index 0000000..108dff5 --- /dev/null +++ b/config/vim/after/ui.vim @@ -0,0 +1,34 @@ +" GUI settings +if has("gui_running") + if has("gui_mac") || has("gui_macvim") + set macligatures + set guifont=JetBrains\ Mono:h14 + set transparency=7 + endif +else + let g:CSApprox_loaded = 1 + + " IndentLine + let g:indentLine_enabled = 1 + let g:indentLine_concealcursor = '' + let g:indentLine_char = '┆' + let g:indentLine_faster = 1 + + if $COLORTERM == 'gnome-terminal' + set term=gnome-256color + else + if $TERM == 'xterm' + set term=xterm-256color + endif + endif +endif + +" if terminal supports 256 colors, disable t_ut +if &term =~ '256color' + set t_ut= +endif + +" set the title of the terminal to the file name +set title +set titleold="Terminal" +set titlestring=%F diff --git a/config/vim/extra/.gitkeep b/config/vim/extra/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/config/vim/ftplugin/go.vim b/config/vim/ftplugin/go.vim new file mode 100644 index 0000000..e8abd59 --- /dev/null +++ b/config/vim/ftplugin/go.vim @@ -0,0 +1,64 @@ +" 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 + +" for go files +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' ]}) diff --git a/config/vim/ftplugin/html.vim b/config/vim/ftplugin/html.vim new file mode 100644 index 0000000..b1eef41 --- /dev/null +++ b/config/vim/ftplugin/html.vim @@ -0,0 +1,3 @@ +" html +" for html files, 2 spaces +autocmd Filetype html setlocal ts=2 sw=2 expandtab diff --git a/config/vim/ftplugin/php.vim b/config/vim/ftplugin/php.vim new file mode 100644 index 0000000..50f0555 --- /dev/null +++ b/config/vim/ftplugin/php.vim @@ -0,0 +1,45 @@ +" php +" Phpactor plugin +" Include use statement +nmap u :call phpactor#UseAdd() +" Invoke the context menu +nmap mm :call phpactor#ContextMenu() +" Invoke the navigation menu +nmap nn :call phpactor#Navigate() +" Goto definition of class or class member under the cursor +nmap oo :call phpactor#GotoDefinition() +nmap oh :call phpactor#GotoDefinition('hsplit') +nmap ov :call phpactor#GotoDefinition('vsplit') +nmap ot :call phpactor#GotoDefinition('tabnew') +" Show brief information about the symbol under the cursor +nmap K :call phpactor#Hover() +" Transform the classes in the current file +nmap tt :call phpactor#Transform() +" Generate a new class (replacing the current file) +nmap cc :call phpactor#ClassNew() +" Extract expression (normal mode) +nmap ee :call phpactor#ExtractExpression(v:false) +" Extract expression from selection +vmap ee :call phpactor#ExtractExpression(v:true) +" Extract method from selection +vmap em :call phpactor#ExtractMethod() + +au FileType php,blade let b:coc_root_patterns = [ + \ '.git', '.env', 'composer.json', 'artisan' + \] +au FileType php,blade nmap ga (coc-codeaction-line) +au FileType php,blade nmap ac (coc-codeaction-cursor) +au FileType php,blade nmap gd (coc-definition) +au FileType php,blade nmap gy (coc-type-definition) +au FileType php,blade nmap gi (coc-implementation) +au FileType php,blade nmap gr (coc-references) +au FileType php,blade nmap K (coc-hover) +au FileType php,blade nmap rn (coc-rename) +au FileType php,blade nmap f (coc-format) +au FileType php,blade nmap qf (coc-fix-current) +au FileType php,blade nmap qo (coc-fix-all) +au FileType php,blade nmap do (coc-diagnostic-prev) +au FileType php,blade nmap dn (coc-diagnostic-next) +au FileType php,blade nmap ca (coc-cursoraction) +au FileType php,blade nmap so (coc-symbols) +au FileType php,blade nmap cs (coc-list-symbols) diff --git a/config/vim/vimrc b/config/vim/vimrc index 0579b77..cadb57c 100644 --- a/config/vim/vimrc +++ b/config/vim/vimrc @@ -33,7 +33,8 @@ endif " {{{ call plug#begin(expand('$HOME/.config/vim/plugged')) - + " vim-sensible + Plug 'tpope/vim-sensible' " coc.nvim - Intellisense engine Plug 'neoclide/coc.nvim', {'branch': 'release'} " editorconfig-vim - EditorConfig plugin @@ -131,91 +132,6 @@ call plug#begin(expand('$HOME/.config/vim/plugged')) call plug#end() " }}} -let mapleader=' ' " Map leader to -filetype off " disable filetype detection (but re-enable later, see below) - -" find matching tags in html/xml documents using matchit -filetype plugin on -packadd! matchit -" disable super buggy netrw -let g:loaded_netrw=1 -let g:netrw_loaded_netrwPlugin=1 -" show JSDoc highlight colors -let g:javascript_plugin_jsdoc=1 - -set backspace=indent,eol,start " Backspace behavior -set cindent " Use 'C' style program indenting -set cursorline " Highlight current line -set encoding=utf-8 " UTF-8 -set expandtab " Use spaces instead of tabs -set fileformats=unix,dos,mac " File formats -set foldmethod=indent " Fold based on indent -set foldlevel=99 " Open all folds -set guioptions=egmrti " GUI options -set hidden " Enable hidden buffers -set ignorecase " Always case-insensitive -set incsearch " Searches for strings incrementally -set laststatus=2 " Always show statusline (even with only single window) -set linespace=3 " Set line spacing -set list " Show invisible characters -set listchars=tab:⌴\ ,trail:◼,nbsp:•,extends:…,precedes:… " Invisible characters -set modeline " Enable modelines -set modelines=3 " Number of lines to check for modelines -set mouse=a " Enable mouse support -set mousemodel=popup " Enable mouse support -set nobackup " Disable backup files -set nocompatible " disable compatibility mode with vi -set nowritebackup " Disable backup files -set number " Show line numbers -set relativenumber " Show relative line numbers -set ruler " Show row and column ruler information -set scrolloff=8 " Minimum number of lines to keep above and below the cursor -set shiftwidth=4 " Number of auto-indent spaces -set shortmess+=A " Don't show autocommand messages -set shortmess+=F " Avoid showing the "file-info" message -set shortmess+=I " Don't show intro message -set shortmess+=O " Avoid showing the "file-read" message -set shortmess+=O " Don't show overlength messages -set shortmess+=T " Don't show title messages -set shortmess+=W " Don't show "written" messages -set shortmess+=a " Avoid showing the "ATTENTION" message -set shortmess+=c " Avoid showing the "ins-completion-menu" message -set shortmess+=c " Don't pass messages to |ins-completion-menu| -set shortmess+=o " Avoid showing the "overlength" message -set shortmess+=t " Avoid showing the "trailing whitespace" message -set showcmd " Show command in status line -set showmatch " Highlight matching brace -set signcolumn=yes " Show sign column -set smartcase " Enable smart-case search -set smartindent " Enable smart-indent -set smarttab " Enable smart-tabs -set softtabstop=4 " Number of spaces per Tab -set spelllang=fi,en " Set the spell language -set spellsuggest=double " Suggest the first word when spell checking -set t_Co=256 " 256 colors -set termguicolors " Enable 24-bit RGB color in the terminal -set timeoutlen=500 " By default timeoutlen=1000 (ms) -set ttimeoutlen=0 " By default ttimeoutlen=-1 (ms) -set undolevels=1000 " Number of undo levels -set visualbell " Use visual bell (no beeping) -set wildmenu " Enable wildmenu -set wildmode=longest,list:longest " Command-line completion mode -set wrap " Wrap lines -set wrapscan " Searches wrap around the end of the file - -" Ignore these files in wildmenu -set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__,vendor - -colorscheme iceberg " Set the color scheme -filetype plugin indent on " enable filetype detection, plugins and indenting - -" Set the shell -if exists('$SHELL') - set shell=$SHELL -else - set shell=/bin/sh -endif - " COC let g:coc_global_extensions = [ \ '@yaegassy/coc-intelephense', @@ -242,41 +158,6 @@ let g:session_autoload = "yes" let g:session_autosave = "yes" let g:session_command_aliases = 1 -" GUI settings -if has("gui_running") - if has("gui_mac") || has("gui_macvim") - set macligatures - set guifont=JetBrains\ Mono:h14 - set transparency=7 - endif -else - let g:CSApprox_loaded = 1 - - " IndentLine - let g:indentLine_enabled = 1 - let g:indentLine_concealcursor = '' - let g:indentLine_char = '┆' - let g:indentLine_faster = 1 - - if $COLORTERM == 'gnome-terminal' - set term=gnome-256color - else - if $TERM == 'xterm' - set term=xterm-256color - endif - endif -endif - -" if terminal supports 256 colors, disable t_ut -if &term =~ '256color' - set t_ut= -endif - -" set the title of the terminal to the file name -set title -set titleold="Terminal" -set titlestring=%F - syntax on " set statusline to show the file name @@ -301,21 +182,6 @@ let g:airline_powerline_fonts = 1 let g:airline_skip_empty_sections = 1 let g:airline_theme = 'iceberg' -"***************************************************************************** -"" Abbreviations -"***************************************************************************** -"" no one is really happy until you have this shortcuts -cnoreabbrev W! w! " force write -cnoreabbrev Q! q! " force quit -cnoreabbrev Qall! qall! " force quit all -cnoreabbrev Wq wq " write and quit -cnoreabbrev Wa wa " write all -cnoreabbrev wQ wq " write and quit -cnoreabbrev WQ wq " write and quit -cnoreabbrev W w " write -cnoreabbrev Q q " quit -cnoreabbrev Qall qall " quit all - " NERDTree configuration let g:NERDTreeChDirMode=2 let g:NERDTreeIgnore=['node_modules', 'vendor', '\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__'] @@ -334,8 +200,6 @@ let Grep_Default_Options = '-IR' let Grep_Skip_Files = '*.log *.db .DS_Store' let Grep_Skip_Dirs = '.git node_modules vendor plugged' -nnoremap sh :terminal " open a new terminal - " CoC (code suggestions, diagnostics and refactoring) " find or update definitions nmap gd (coc-definition) @@ -435,107 +299,10 @@ if !exists('*s:setupWrapping') endfunction endif -function! ChangeColorScheme(channel, msg) - let time = trim(a:msg) - if time ==# "Dark" - set background="dark" - else - set background="light" - endif -endfunction - -function! CheckStatus(timer) - if executable("defaults") - let job = job_start( - \ ["defaults", "read", "-g", "AppleInterfaceStyle"], - \ {"out_cb": "ChangeColorScheme"} - \ ) - else - set background="dark" - endif -endfunction - -function! AutoDarkModeSetup() - let timer = timer_start(3000, 'CheckStatus', {'repeat': -1}) - call CheckStatus(timer) " Initial call to setup the theme -endfunction - -call AutoDarkModeSetup() - "***************************************************************************** -"" Autocmd Rules +"" Custom configs "***************************************************************************** -"" The PC is fast enough, do syntax highlight -"" syncing from start 6nless 200 lines -augroup vimrc-sync-fromstart - autocmd! - autocmd BufEnter * :syntax sync maxlines=600 -augroup END - -"" txt -augroup vimrc-wrapping - autocmd! - autocmd BufRead,BufNewFile *.txt call s:setupWrapping() -augroup END - -"" make/cmake -augroup vimrc-make-cmake - autocmd! - autocmd FileType make setlocal noexpandtab - autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake -augroup END - -set autoread - -"***************************************************************************** -"" Mappings -"***************************************************************************** - -noremap :w " save buffer - -"" Split -noremap h :split " horizontal split -noremap v :vsplit " vertical split - -" Git -noremap ga :Gwrite -noremap gc :Git commit --verbose -noremap gsh :Git push -noremap gll :Git pull -noremap gs :Git -noremap gb :Git blame -noremap gd :Gvdiffsplit -noremap gr :GRemove - -" session management -nnoremap so :OpenSession -nnoremap ss :SaveSession -nnoremap sd :DeleteSession -nnoremap sc :CloseSession - -" Tabs -nnoremap gt " next tab -nnoremap gT " previous tab -nnoremap :tabnew " new tab - -nnoremap . :lcd %:p:h " set working directory to the current file - -"" Opens an edit command with the path of the currently edited file filled in -noremap e :e =expand("%:p:h") . "/" - -"" Opens a tab edit command with the path of the currently edited file filled -noremap r :tabe =expand("%:p:h") . "/" - -"" fzf.vim -let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'vendor/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null" - -cnoremap =expand("%:p:h") . "/" -nnoremap b :Buffers -nnoremap e :FZF -m -" Recovery commands from history through FZF -nmap y :History: - " ale let g:ale_linters = { \ "vim": [ "vint" ] @@ -543,127 +310,6 @@ let g:ale_linters = { let g:ale_fixers = { \} -" Tagbar -nmap :TagbarToggle " open tagbar -let g:tagbar_autofocus = 1 - -" Disable visualbell -set noerrorbells visualbell t_vb= -if has('autocmd') - autocmd GUIEnter * set visualbell t_vb= -endif - -"" Copy/Paste/Cut -if has('unnamedplus') - set clipboard=unnamed,unnamedplus -endif - -noremap YY "+y " copy line -noremap p "+gP " paste -noremap XX "+x " cut - -if has('macunix') - " pbcopy for OSX copy/paste - vmap :!pbcopy " copy - vmap :w !pbcopy " cut - vmap :!pbpaste " paste -endif - -"" Buffer nav -noremap z :bp " previous buffer -noremap x :bn " next buffer -noremap bq :bp " previous buffer -noremap bw :bn " next buffer -noremap bd :bd " close buffer - -nnoremap :noh " clean search - -"" Switching windows -noremap j " move to window below -noremap k " move to window above -noremap l " move to window right -noremap h " move to window left - -vmap < >gv " move visual block right, keep selection -vnoremap J :m '>+1gv=gv " move visual block down, keep selection -vnoremap K :m '<-2gv=gv " move visual block up, keep selection - -nnoremap o :.GBrowse " open current line on GitHub - -"***************************************************************************** -"" 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 - -" for go files -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' ]}) - -" html -" for html files, 2 spaces -autocmd Filetype html setlocal ts=2 sw=2 expandtab - " javascript let g:javascript_enable_domhtmlcss = 1 @@ -673,36 +319,6 @@ augroup vimrc-javascript autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4 augroup END -" php -" Phpactor plugin -" Include use statement -nmap u :call phpactor#UseAdd() -" Invoke the context menu -nmap mm :call phpactor#ContextMenu() -" Invoke the navigation menu -nmap nn :call phpactor#Navigate() -" Goto definition of class or class member under the cursor -nmap oo :call phpactor#GotoDefinition() -nmap oh :call phpactor#GotoDefinition('hsplit') -nmap ov :call phpactor#GotoDefinition('vsplit') -nmap ot :call phpactor#GotoDefinition('tabnew') -" Show brief information about the symbol under the cursor -nmap K :call phpactor#Hover() -" Transform the classes in the current file -nmap tt :call phpactor#Transform() -" Generate a new class (replacing the current file) -nmap cc :call phpactor#ClassNew() -" Extract expression (normal mode) -nmap ee :call phpactor#ExtractExpression(v:false) -" Extract expression from selection -vmap ee :call phpactor#ExtractExpression(v:true) -" Extract method from selection -vmap em :call phpactor#ExtractMethod() - -au FileType php,blade let b:coc_root_patterns = ['.git', '.env', 'composer.json', 'artisan'] -au FileType php,blade nmap ga (coc-codeaction-line) -au FileType php,blade nmap ac (coc-codeaction-cursor) - " python " vim-python augroup vimrc-python