From e055444bf3e4ec8557c501ae8f0b1b18857ed4c4 Mon Sep 17 00:00:00 2001 From: Thomas Ruoff Date: Sat, 30 Oct 2021 00:14:06 +0200 Subject: [PATCH] update vim config yet again --- vim/.vimrc | 349 +++++++++++++++++++++-------------------------------- 1 file changed, 136 insertions(+), 213 deletions(-) diff --git a/vim/.vimrc b/vim/.vimrc index 4c31845..93d167d 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -2,13 +2,19 @@ " author: Thomas Ruoff " Basics {{{ -set encoding=utf-8 +if has('vim_starting') + set encoding=utf-8 + scriptencoding utf-8 + + set clipboard& clipboard^=unnamed,unnamedplus +endif + set hidden set ttyfast set lazyredraw set updatetime=300 -set synmaxcol=512 +set synmaxcol=2000 set modeline @@ -20,23 +26,13 @@ set mousehide set wildmode=list:longest,full set wildignore+=*.swp,*.bak,*.jpg,*.gif,*.png,*.git, +set wildignore+=**/node_modules/** set splitright set splitbelow -" Always show the status line -set laststatus=2 -set cmdheight=2 - set shortmess+=c -" yank delete change and put operations go by default in `"+` register -" so in the systems clipboard accessable by CTRL-V on all OS types -if has('mac') - set clipboard^=unnamed -else - set clipboard^=unnamedplus -endif " set ignorecase set infercase @@ -65,162 +61,171 @@ set showmatch set spellcapcheck= set complete+=kspell -let mapleader=" " -let maplocalleader=" " +if has('vim_starting') + let g:mapleader="\" + let g:maplocalleader=";" + + nnoremap + xnoremap + nnoremap , + xnoremap , + nnoremap ; + xnoremap ; +endif " netrw +let g:netrw_fastbrowse = 0 let g:netrw_banner = 0 -let g:netrw_liststyle = 3 -let g:netrw_browse_split = 3 " sort is affecting only: directories on the top, files below let g:netrw_sort_sequence = '[\/]$,*' " }}} " Plugins {{{ -call plug#begin('~/.vim/plugged') +call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged') + Plug 'tpope/vim-sensible' Plug 'tpope/vim-unimpaired' Plug 'tpope/vim-surround' Plug 'tpope/vim-abolish' - +Plug 'tpope/vim-vinegar' +Plug 'tpope/vim-projectionist' Plug 'tpope/vim-fugitive' -Plug 'tpope/vim-rhubarb' -Plug 'airblade/vim-gitgutter' -Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } -Plug 'junegunn/fzf.vim' - nnoremap b :Buffers - nnoremap f :GFiles - nnoremap F :Files - nnoremap c :Commits - nnoremap w :Windows - nnoremap m :Maps - nnoremap h :Helptags - nnoremap / :Rg - nnoremap * :Rg - nnoremap C :Commands +Plug 'andymass/vim-matchup' -Plug 'junegunn/vim-peekaboo' Plug 'machakann/vim-highlightedyank' Plug 'editorconfig/editorconfig-vim' let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*'] -Plug 'tpope/vim-projectionist' - Plug 'mbbill/undotree' - nnoremap u :UndotreeToggle - -Plug 'neoclide/coc.nvim', {'branch': 'release'} - " Remap keys for gotos - nmap gd (coc-definition) - nmap gy (coc-type-definition) - nmap gi (coc-implementation) - nmap gr (coc-references) - - " Use `[d` and `]d` to navigate diagnostics - nmap [d (coc-diagnostic-prev) - nmap ]d (coc-diagnostic-next) - " Remap for rename current word - nmap rn (coc-rename) - " Remap for do codeAction of current line - nmap ac (coc-codeaction) - " Applying codeAction to the selected region. - " Example: `aap` for current paragraph - xmap a (coc-codeaction-selected) - nmap a (coc-codeaction-selected) - " Fix autofix problem of current line - nmap qf (coc-fix-current) - " Use to trigger completion. - if has('nvim') - inoremap coc#refresh() - else - inoremap coc#refresh() - endif - - " Make auto-select the first completion item and notify coc.nvim to - " format on enter, could be remapped by other vim plugin - inoremap pumvisible() ? coc#_select_confirm() - \: "\u\\=coc#on_enter()\" - - " Use K to show documentation in preview window. - nnoremap K :call show_documentation() - - function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - elseif (coc#rpc#ready()) - call CocActionAsync('doHover') - else - execute '!' . &keywordprg . " " . expand('') - endif - endfunction - - " Formatting selected code. - xmap cf (coc-format-selected) - nmap cf (coc-format-selected) - -Plug 'itchyny/lightline.vim' - if filereadable(expand("~/.vim/lightline.vim")) - source ~/.vim/lightline.vim - endif - - function! LightlineReload() - call lightline#init() - call lightline#colorscheme() - call lightline#update() - endfunction - -Plug 'lifepillar/vim-gruvbox8' +" TODO snippets https://www.lunarvim.org/plugins/02-default-plugins.html#snippets Plug 'SirVer/ultisnips' - let g:UltiSnipsExpandTrigger="" - let g:UltiSnipsJumpForwardTrigger="" - let g:UltiSnipsJumpBackwardTrigger="" -Plug 'pangloss/vim-javascript' -Plug 'MaxMEllon/vim-jsx-pretty' +" Plug 'pangloss/vim-javascript' +" Plug 'MaxMEllon/vim-jsx-pretty' -Plug 'sheerun/vim-polyglot' - let g:polyglot_disabled = ['javascript', 'jsx', 'latex'] +" Plug 'sheerun/vim-polyglot' +" let g:polyglot_disabled = ['javascript', 'jsx', 'latex'] -Plug 'lervag/vimtex', { 'for': 'tex' } - let g:vimtex_view_method = 'zathura' +" Plug 'lervag/vimtex', { 'for': 'tex' } +" let g:vimtex_view_method = 'zathura' Plug 'wellle/targets.vim' Plug 'janko-m/vim-test' - nmap t :TestNearest - nmap T :TestFile let test#strategy = "neovim" -" vim 8 plugins -" if v:version >= 800 -" Plug 'ludovicchabant/vim-gutentags' -" let g:gutentags_cache_dir="~/.tags" -" let g:gutentags_file_list_command = { -" \ 'markers': { -" \ '.git': 'git ls-files', -" \ '.hg': 'hg files', -" \ }, -" \ } -" endif - -Plug 'preservim/nerdtree' - nmap n :NERDTreeToggle - nmap N :NERDTreeFind +" Plug 'ludovicchabant/vim-gutentags' +" let g:gutentags_cache_dir="~/.tags" +" let g:gutentags_file_list_command = { +" \ 'markers': { +" \ '.git': 'git ls-files', +" \ '.hg': 'hg files', +" \ }, +" \ } Plug 'ap/vim-css-color' Plug 'godlygeek/tabular' Plug 'plasticboy/vim-markdown' +Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } + +" Lua Plugins +Plug 'RRethy/nvim-base16' + +Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} + +Plug 'neovim/nvim-lspconfig' +Plug 'jose-elias-alvarez/null-ls.nvim' +Plug 'kabouzeid/nvim-lspinstall' +"Plug 'tamago324/nlsp-settings.nvim' +Plug 'folke/trouble.nvim' + +Plug 'kyazdani42/nvim-web-devicons' " for file icons +Plug 'kyazdani42/nvim-tree.lua' + +Plug 'ahmedkhalf/project.nvim' + +Plug 'nvim-lua/plenary.nvim' +Plug 'nvim-telescope/telescope.nvim' + nnoremap f :Telescope find_files + +Plug 'lewis6991/gitsigns.nvim' +Plug 'windwp/nvim-autopairs' + +Plug 'folke/which-key.nvim' + +" TODO compnletion https://github.com/hrsh7th/nvim-cmp + +Plug 'hoob3rt/lualine.nvim' + + " debug -Plug 'tweekmonster/startuptime.vim' +" Plug 'tweekmonster/startuptime.vim' call plug#end() + +lua << EOF + require('nvim-treesitter.configs').setup{ + hightlight = { enabled = true }, + incremental_selection = { enable = false }, + ensure_installed = {'javascript'} + } + + require("null-ls").config({ }) + require("lspconfig")["null-ls"].setup({ }) + require('lspinstall').setup{} + local servers = require('lspinstall').installed_servers() + for _, server in pairs(servers) do + require'lspconfig'[server].setup{} + end + + require("trouble").setup{} + + require'nvim-web-devicons'.setup{} + require('nvim-tree').setup{} + + require('project_nvim').setup{} + + require('telescope').setup{} + -- require('telescope').load_extension('projects') + + require('gitsigns').setup{} + + require('nvim-autopairs').setup{} + + local wk = require('which-key') + wk.setup() + wk.register({ + c = {"bd", "close"}, + s = "save", + h = "gitsigns", + f ={ + name = "file", + f = { "Telescope find_files", "Find File" }, + r = { "Telescope oldfiles", "Open Recent File" }, + c = { "e $MYVIMRC", "Open config" }, + }, + g = { + name = "git", + g = {"Git", "fugitive"} + }, + t = { + name = "test", + n = {"TestNearest", "Test Nearest"}, + f = {"TestFile", "Test File"}, + l = {"TestLast", "Test Last"}, + } + }, { prefix = ""}) + + require('lualine').setup{ theme = 'gruvbox'} +EOF + " }}} " Local .vimrc {{{ @@ -261,7 +266,7 @@ set diffopt+=iwhite " }}} " {{{ Undo -set undodir=~/.vim/undos,/tmp +set undodir=$VIM_DATA_PATH/undos set undofile set undolevels=1000 set undoreload=10000 @@ -271,50 +276,17 @@ set undoreload=10000 " set cursorline set background=dark -colorscheme gruvbox8 - +colorscheme base16-gruvbox-dark-medium set number -" }}} -" GUI Settings {{{ -if has("gui_running") - "disable menu, toolsbar, scrollbar - set guioptions -=m - set guioptions -=T - set guioptions -=r -endif " }}} " Key mappings {{{ "" fast escaping inoremap jk - -"" delete buffer (and keep split) -noremap d :bp\|bd # - -"" indent visual selected code without unselecting and going back to normal mode -vnoremap > >gv -vnoremap < ss :mks! ' . g:sessions_dir . '/*.vim' -exec 'nnoremap sr :so ' . g:sessions_dir. '/*.vim' - -"" fast editing of config -nnoremap ev :e $MYVIMRC - -"" cheatsheet -nnoremap ec :e ~/.vim/cheatsheet.md - -" debugging, use leader-DD to start, do a slow action, then leader-DQ to -" finish. Your output will be in profile.log -nnoremap DD :exe ":profile start profile.log":exe ":profile func *":exe ":profile file *" -nnoremap DQ :exe ":profile pause":noautocmd qall! +"" toggle fold +nnoremap za "" abbreviations cnoreabbrev W! w! @@ -327,56 +299,7 @@ cnoreabbrev WQ wq cnoreabbrev W w cnoreabbrev Q q cnoreabbrev Qall qall - -iab xnow =strftime("%Y-%m-%d %H:%M") -" }}} - -" Autocmd Rules {{{ - -augroup general - autocmd! - "" do syntax highlight syncing from start - autocmd BufEnter * :syntax sync fromstart -augroup END - -"" txt, mail, tex -augroup text - autocmd! - autocmd FileType text,markdown,mail,tex set wrap wm=2 nocindent spell textwidth=79 -augroup END - -augroup markdown - autocmd! - autocmd FileType markdown set wrap wm=2 nocindent spell textwidth=79 -augroup END - -"" Web -augroup web - autocmd! - autocmd FileType javascript map r :TernRename - autocmd BufRead,BufNewFile *.template set filetype=html.mustache syntax=mustache - autocmd BufRead,BufNewFile *.html set spell -augroup END - -"" Help -augroup HelpInTabs - autocmd! - autocmd BufEnter *.txt call HelpInNewTab() -augroup END - -"Only apply to help files... -function! HelpInNewTab () - if &buftype == 'help' - "Convert the help window to a tab... - execute "normal \T" - endif -endfunction - -" Reloading vim -augroup VimReload - autocmd! - autocmd BufWritePost $MYVIMRC source $MYVIMRC | call LightlineReload() -augroup END +cnoreabbrev csfr csrf " }}}