diff --git a/home/.chezmoidata.yaml b/home/.chezmoidata.yaml index c5c83c25..64d9627d 100644 --- a/home/.chezmoidata.yaml +++ b/home/.chezmoidata.yaml @@ -1536,6 +1536,7 @@ softwarePlugins: - https://github.com/tpope/vim-surround.git - https://github.com/vim-airline/vim-airline.git - https://github.com/vim-syntastic/syntastic.git + - https://github.com/leafgarland/typescript-vim.git qubes: dom0Packages: - bismuth @@ -1576,4 +1577,4 @@ qubes: perfectStack: darwin: - - warp-terminal \ No newline at end of file + - warp-terminal diff --git a/home/.chezmoiscripts/universal/run_onchange_after_39-vim-plugins.sh.tmpl b/home/.chezmoiscripts/universal/run_onchange_after_39-vim-plugins.sh.tmpl index c2e4df30..4a01d174 100644 --- a/home/.chezmoiscripts/universal/run_onchange_after_39-vim-plugins.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_onchange_after_39-vim-plugins.sh.tmpl @@ -6,6 +6,9 @@ # This script pre-installs the VIM plugins defined in [`.chezmoidata.yaml`](https://github.com/megabyte-labs/install.doctor/tree/master/home/.chezmoidata.yaml) # so that VIM does not have to do anything on its first launch. +{{ includeTemplate "universal/profile" }} +{{ includeTemplate "universal/logg" }} + function vimSetup() { ### Run the VIM plugin install routine if command -v vim > /dev/null; then diff --git a/home/dot_config/shell/aliases.sh.tmpl b/home/dot_config/shell/aliases.sh.tmpl index e4023089..e30dedca 100644 --- a/home/dot_config/shell/aliases.sh.tmpl +++ b/home/dot_config/shell/aliases.sh.tmpl @@ -71,12 +71,12 @@ fi ### VIM if command -v vim > /dev/null; then - alias vi='vim' - alias v='vim' + alias vi="vim" + alias v="vim" fi ### NVIM if command -v nvim > /dev/null; then - alias nvim='env -u VIMINIT nvim' + alias nvim='env -u VIMINIT -u MYVIMRC nvim' fi ### mitmproxy / mitmweb diff --git a/home/dot_config/vim/vimrc b/home/dot_config/vim/vimrc index 8685c01b..314538b3 100644 --- a/home/dot_config/vim/vimrc +++ b/home/dot_config/vim/vimrc @@ -1,63 +1,401 @@ +set runtimepath=~/.config/vim,~/.config/vim/autoload,~/.config/vim/colors,$VIMRUNTIME,$VIM + +" Sets how many lines of history VIM has to remember +set history=500 + +" Enable filetype plugins +filetype plugin on +filetype indent on + +" Set to auto read when a file is changed from the outside +set autoread +au FocusGained,BufEnter * checktime + +" With a map leader it's possible to do extra key combinations +" like w saves the current file +let mapleader = "," + +" Fast saving +nmap w :w! + +" :W sudo saves the file +" (useful for handling the permission-denied error) +command! W execute 'w !sudo tee % > /dev/null' edit! + +" Set 7 lines to the cursor - when moving vertically using j/k +set so=7 + +" Turn on the Wild menu +set wildmenu + +" Ignore compiled files +set wildignore=*.o,*~,*.pyc +if has("win16") || has("win32") + set wildignore+=.git\*,.hg\*,.svn\* +else + set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store +endif + +" Always show current position +set ruler + +" Height of the command bar +set cmdheight=1 + +" A buffer becomes hidden when it is abandoned +set hid + +" Configure backspace so it acts as it should act +set backspace=eol,start,indent +set whichwrap+=<,>,h,l + +" Ignore case when searching +set ignorecase + +" When searching try to be smart about cases +set smartcase + +" Highlight search results +set hlsearch + +" Makes search act like search in modern browsers +set incsearch + +" Don't redraw while executing macros (good performance config) +set lazyredraw + +" For regular expressions turn magic on +set magic + +" Show matching brackets when text indicator is over them +set showmatch + +" How many tenths of a second to blink when matching brackets +set mat=2 + +" No annoying sound on errors +set noerrorbells +set novisualbell +set t_vb= +set tm=500 + +" Add a bit extra margin to the left +set foldcolumn=1 + +" Set regular expression engine automatically +set regexpengine=0 + +" Enable 256 colors palette in Gnome Terminal +if $COLORTERM == 'gnome-terminal' + set t_Co=256 +endif + +" Set extra options when running in GUI mode +if has("gui_running") + set guioptions-=T + set guioptions-=e + set t_Co=256 + set guitablabel=%M\ %t +endif + +" Use Unix as the standard file type +set ffs=unix,dos,mac + +" Use spaces instead of tabs +set expandtab + +" Be smart when using tabs ;) +set smarttab + +" 1 tab == 2 spaces +set shiftwidth=2 +set tabstop=2 + +" Linebreak on 500 characters +set lbr +set tw=200 + +set ai "Auto indent +set si "Smart indent +set wrap "Wrap lines + +" Visual mode pressing * or # searches for the current selection +" Super useful! From an idea by Michael Naumann +vnoremap * :call VisualSelection('', '')/=@/ +vnoremap # :call VisualSelection('', '')?=@/ + +" Smart way to move between windows +map j +map k +map h +map l + +" Close the current buffer +map bd :Bclose:tabclosegT + +" Close all the buffers +map ba :bufdo bd + +map l :bnext +map h :bprevious + +" Useful mappings for managing tabs +map tn :tabnew +map to :tabonly +map tc :tabclose +map tm :tabmove +map t :tabnext + +" Always show the status line +set laststatus=2 + +" Format the status line +set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c + +" Remap VIM 0 to first non-blank character +map 0 ^ + +" Move a line of text using ALT+[jk] or Command+[jk] on mac +nmap mz:m+`z +nmap mz:m-2`z +vmap :m'>+`mzgv`yo`z +vmap :m'<-2`>my` + nmap + vmap + vmap +endif + +" Delete trailing white space on save, useful for some filetypes ;) +fun! CleanExtraSpaces() + let save_cursor = getpos(".") + let old_query = getreg('/') + silent! %s/\s\+$//e + call setpos('.', save_cursor) + call setreg('/', old_query) +endfun + +if has("autocmd") + autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces() +endif + +" Pressing ,ss will toggle and untoggle spell checking +map ss :setlocal spell! + +" Shortcuts using +map sn ]s +map sp [s +map sa zg +map s? z= + +" Remove the Windows ^M - when the encodings gets messed up +noremap m mmHmt:%s///ge'tzt'm + +" Quickly open a buffer for scribble +map q :e ~/buffer + +" Quickly open a markdown buffer for scribble +map x :e ~/buffer.md + +" Toggle paste mode on and off +map pp :setlocal paste! + +" Helper Functions +" Returns true if paste mode is enabled +function! HasPaste() + if &paste + return 'PASTE MODE ' + endif + return '' +endfunction + +" Don't close window, when deleting a buffer +command! Bclose call BufcloseCloseIt() +function! BufcloseCloseIt() + let l:currentBufNum = bufnr("%") + let l:alternateBufNum = bufnr("#") + + if buflisted(l:alternateBufNum) + buffer # + else + bnext + endif + + if bufnr("%") == l:currentBufNum + new + endif + + if buflisted(l:currentBufNum) + execute("bdelete! ".l:currentBufNum) + endif +endfunction + +function! CmdLine(str) + call feedkeys(":" . a:str) +endfunction + +function! VisualSelection(direction, extra_filter) range + let l:saved_reg = @" + execute "normal! vgvy" + + let l:pattern = escape(@", "\\/.*'$^~[]") + let l:pattern = substitute(l:pattern, "\n$", "", "") + + if a:direction == 'gv' + call CmdLine("Ack '" . l:pattern . "' " ) + elseif a:direction == 'replace' + call CmdLine("%s" . '/'. l:pattern . '/') + endif + + let @/ = l:pattern + let @" = l:saved_reg +endfunction + +" Fast editing and reloading of vimrc configs +map e :e! ~/.vim_runtime/my_configs.vim +autocmd! bufwritepost ~/.vim_runtime/my_configs.vim source ~/.vim_runtime/my_configs.vim + + +" Turn persistent undo on means that you can undo even when you close a buffer/VIM +try + set undodir=~/.config/.vim/temp_dirs/undodir + set undofile +catch +endtry + +" Parenthesis/bracket +vnoremap $1 `>a)` +vnoremap $2 `>a]` +vnoremap $3 `>a}` +vnoremap $$ `>a"` +vnoremap $q `>a'` +vnoremap $e `>a`` + +" Map auto complete of (, ", ', [ +inoremap $1 ()i +inoremap $2 []i +inoremap $3 {}i +inoremap $4 {o}O +inoremap $q ''i +inoremap $e ""i + +" Python section +let python_highlight_all = 1 +au FileType python syn keyword pythonDecorator True None False self + +au BufNewFile,BufRead *.jinja set syntax=htmljinja +au BufNewFile,BufRead *.mako set ft=mako + +au FileType python map F :set foldmethod=indent + +au FileType python inoremap $r return +au FileType python inoremap $i import +au FileType python inoremap $p print +au FileType python inoremap $f # --- a +au FileType python map 1 /class +au FileType python map 2 /def +au FileType python map C ?class +au FileType python map D ?def + +" JavaScript section +au FileType javascript call JavaScriptFold() +au FileType javascript setl fen +au FileType javascript setl nocindent + +au FileType javascript,typescript imap console.log();hi +au FileType javascript,typescript imap alert();hi + +au FileType javascript,typescript inoremap $r return +au FileType javascript,typescript inoremap $f // --- PHFP2xi + +function! JavaScriptFold() + setl foldmethod=syntax + setl foldlevelstart=1 + syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend + + function! FoldText() + return substitute(getline(v:foldstart), '{.*', '{...}', '') + endfunction + setl foldtext=FoldText() +endfunction + +" Shell section +if exists('$TMUX') + if has('nvim') + set termguicolors + else + set term=screen-256color + endif +endif + +" Markdown +let vim_markdown_folding_disabled = 1 + +" YAML +autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab + " Install Coc extensions " TODO: Add https://github.com/yuki-yano/fzf-preview.vim " TODO: Add https://github.com/tpope/vim-fugitive let g:coc_global_config="$HOME/.config/coc/coc-settings.json" let g:coc_global_extensions = [ - '@yaegassy/coc-ansible', - '@yaegassy/coc-nginx', - 'coc-angular', - 'coc-blade', - 'coc-calc', - 'coc-clangd', - 'coc-copilot', - 'coc-css', - 'coc-cssmodules', - 'coc-deno', - 'coc-diagnostic', - 'coc-docker', - 'coc-emmet', - 'coc-eslint', - 'coc-explorer', - 'coc-flutter', - 'coc-git', - 'coc-go', - 'coc-highlight', - 'coc-html-css-support', - 'coc-html', - 'coc-htmlhint', - 'coc-java', - 'coc-jedi', - 'coc-json', - 'coc-ltex', - 'coc-lua', - 'coc-markdown-preview-enhanced', - 'coc-markdownlint', - 'coc-markmap', - 'coc-phpls', - 'coc-powershell', - 'coc-prettier', - 'coc-prisma', - 'coc-pyright', - 'coc-rls', - 'coc-rust-analyzer', - 'coc-sh', - 'coc-solargraph', - 'coc-solidity', - 'coc-spell-checker', - 'coc-stylelint', - 'coc-sql', - 'coc-sqlfluff', - 'coc-svelte', - 'coc-svg', - 'coc-swagger', - 'coc-symbol-line', - 'coc-tailwindcss', - 'coc-toml', - 'coc-tsserver', - 'coc-xml', - 'coc-yaml', - 'coc-yank' -] + \'@yaegassy/coc-ansible', + \'@yaegassy/coc-nginx', + \'coc-angular', + \'coc-blade', + \'coc-calc', + \'coc-clangd', + \'coc-copilot', + \'coc-css', + \'coc-cssmodules', + \'coc-deno', + \'coc-diagnostic', + \'coc-docker', + \'coc-emmet', + \'coc-eslint', + \'coc-explorer', + \'coc-flutter', + \'coc-git', + \'coc-go', + \'coc-highlight', + \'coc-html-css-support', + \'coc-html', + \'coc-htmlhint', + \'coc-java', + \'coc-jedi', + \'coc-json', + \'coc-ltex', + \'coc-lua', + \'coc-markdown-preview-enhanced', + \'coc-markdownlint', + \'coc-markmap', + \'coc-phpls', + \'coc-powershell', + \'coc-prettier', + \'coc-prisma', + \'coc-pyright', + \'coc-rls', + \'coc-rust-analyzer', + \'coc-sh', + \'coc-solargraph', + \'coc-solidity', + \'coc-spell-checker', + \'coc-stylelint', + \'coc-sql', + \'coc-sqlfluff', + \'coc-svelte', + \'coc-svg', + \'coc-swagger', + \'coc-symbol-line', + \'coc-tailwindcss', + \'coc-toml', + \'coc-tsserver', + \'coc-xml', + \'coc-yaml', + \'coc-yank' +\] " Settings for coc-css extension autocmd FileType scss setl iskeyword+=@-@ @@ -68,7 +406,7 @@ autocmd BufWritePre *.go :silent call CocAction('runCommand', 'editor.action.org syntax enable set background=dark colorscheme Betelgeuse -set g:lightline = { 'colorscheme': 'Betelgeuse' } +let g:lightline = { 'colorscheme': 'Betelgeuse' } " Settings for plugin https://github.com/neoclide/coc.nvim.git autocmd FileType json syntax match Comment +\/\/.\+$+ @@ -86,36 +424,34 @@ let g:syntastic_check_on_wq = 0 set encoding=UTF-8 " Set location of viminfo file -set viminfo="$HOME/.config/vim/viminfo" +set viminfo+=n~/.config/vim/viminfo -silent! call plug#begin() -Plug '${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/ale' -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/coc.nvim" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/copilot.vim" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/dockerfile.vim" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/editorconfig-vim" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/fzf.vim" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/fzf" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/lightline.vim" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/nerdtree" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/php.vim" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/python-syntax" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/syntastic" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/typescript-vim" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vim-airline" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vim-carbon-now-sh" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vim-devicons" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vim-five" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vim-go" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vim-javascript" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vim-jsx" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vim-markdown" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vim-multiple-cursors" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vim-prettier" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vim-sensible" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vim-surround" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/vimgutter" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/zoxide.vim" -Plug "${XDG_DATA_HOME:-$HOME/.local/share}/vim/plugged/ansible-vim", {"do": "./UltiSnips/generate.sh"} +silent! call plug#begin('~/.local/share/vim/plugged') +Plug '~/.local/share/vim/plugged/ale' +Plug '~/.local/share/vim/plugged/coc.nvim' +Plug '~/.local/share/vim/plugged/copilot.vim' +Plug '~/.local/share/vim/plugged/dockerfile.vim' +Plug '~/.local/share/vim/plugged/editorconfig-vim' +Plug '~/.local/share/vim/plugged/fzf.vim' +Plug '~/.local/share/vim/plugged/fzf' +Plug '~/.local/share/vim/plugged/lightline.vim' +Plug '~/.local/share/vim/plugged/nerdtree' +Plug '~/.local/share/vim/plugged/php.vim' +Plug '~/.local/share/vim/plugged/python-syntax' +Plug '~/.local/share/vim/plugged/syntastic' +Plug '~/.local/share/vim/plugged/typescript-vim' +Plug '~/.local/share/vim/plugged/vim-airline' +Plug '~/.local/share/vim/plugged/vim-carbon-now-sh' +Plug '~/.local/share/vim/plugged/vim-devicons' +Plug '~/.local/share/vim/plugged/vim-go' +Plug '~/.local/share/vim/plugged/vim-javascript' +Plug '~/.local/share/vim/plugged/vim-jsx' +Plug '~/.local/share/vim/plugged/vim-markdown' +Plug '~/.local/share/vim/plugged/vim-multiple-cursors' +Plug '~/.local/share/vim/plugged/vim-prettier' +Plug '~/.local/share/vim/plugged/vim-sensible' +Plug '~/.local/share/vim/plugged/vim-surround' +Plug '~/.local/share/vim/plugged/vim-gitgutter' +Plug '~/.local/share/vim/plugged/zoxide.vim' +Plug '~/.local/share/vim/plugged/ansible-vim', {'do': './UltiSnips/generate.sh'} call plug#end() -