diff --git a/nvim/init.vim b/nvim/init.vim index 8a4a5b6..2107eb5 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -40,12 +40,10 @@ set nobackup set nowritebackup set cmdheight=2 set updatetime=300 +set timeoutlen=400 " Don't pass messages to |ins-completion-menu|. set shortmess+=c -" lsp handled by coc -let g:ale_disable_lsp = 1 - " Install vim-plug if not found if empty(glob('~/.vim/autoload/plug.vim')) silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs @@ -55,7 +53,7 @@ endif " Run PlugInstall if there are missing plugins autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) \| PlugInstall --sync | source $MYVIMRC -\| endif + \| endif call plug#begin('~/.vim/plugged') @@ -88,6 +86,12 @@ if has('nvim') Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} Plug 'TimUntersberger/neogit' + Plug 'neovim/nvim-lspconfig' + Plug 'williamboman/nvim-lsp-installer' + Plug 'ray-x/lsp_signature.nvim' + Plug 'simrat39/symbols-outline.nvim' + Plug 'jose-elias-alvarez/null-ls.nvim' + Plug 'NTBBloodbath/doom-one.nvim' Plug 'Mofiqul/dracula.nvim' Plug 'projekt0n/github-nvim-theme' @@ -97,7 +101,7 @@ else Plug 'mhinz/vim-startify' Plug 'preservim/nerdtree' | Plug 'Xuyuanp/nerdtree-git-plugin' Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] } - " vim colorschemes + Plug 'joshdick/onedark.vim' Plug 'kaicataldo/material.vim', { 'branch': 'main' } Plug 'morhetz/gruvbox' @@ -107,34 +111,63 @@ endif call plug#end() if has('nvim') - source ~/.config/nvim/plugins/bufferline.lua - " source ~/.config/nvim/plugins/marks.lua - source ~/.config/nvim/plugins/whichkey.lua - source ~/.config/nvim/plugins/dashboard-nvim.lua - source ~/.config/nvim/plugins/nvimtree.lua - source ~/.config/nvim/plugins/treesitter.lua - source ~/.config/nvim/plugins/neogit.lua + source ~/.config/nvim/plugin-confs/bufferline.lua + " source ~/.config/nvim/plugin-confs/marks.lua + source ~/.config/nvim/plugin-confs/whichkey.lua + source ~/.config/nvim/plugin-confs/dashboard-nvim.lua + source ~/.config/nvim/plugin-confs/dashboard-art.vim + source ~/.config/nvim/plugin-confs/nvimtree.lua + source ~/.config/nvim/plugin-confs/treesitter.lua + source ~/.config/nvim/plugin-confs/neogit.lua + " source ~/.config/nvim/plugin-confs/lspconfig.lua + source ~/.config/nvim/plugin-confs/lsp-signature.lua + source ~/.config/nvim/symbols-outline.lua + " source ~/.config/nvim/null-ls.lua - source ~/.config/nvim/plugins/doomone.lua - " source ~/.config/nvim/plugins/dracula.lua - " source ~/.config/nvim/plugins/github-theme.lua + source ~/.vim/plugin-confs/fzf.vim + source ~/.vim/plugin-confs/vim-closetag.vim + source ~/.vim/plugin-confs/wakatime.vim + source ~/.vim/plugin-confs/lightline.vim + source ~/.vim/plugin-confs/floaterm.vim + + source ~/.vim/plugin-confs/ale.vim + source ~/.vim/plugin-confs/coc.vim + + source ~/.config/nvim/plugin-confs/doomone.lua + source ~/.config/nvim/plugin-confs/dracula.lua + source ~/.config/nvim/plugin-confs/github-theme.lua " makes fzf match colorscheme (I think) augroup fzf_preview autocmd! autocmd User fzf_preview#rpc#initialized call s:fzf_preview_settings() " fzf_preview#remote#initialized or fzf_preview#coc#initialized augroup END - function! s:fzf_preview_settings() abort let g:fzf_preview_command = 'COLORTERM=truecolor ' . g:fzf_preview_command let g:fzf_preview_grep_preview_cmd = 'COLORTERM=truecolor ' . g:fzf_preview_grep_preview_cmd endfunction " make terminal not have line numbers autocmd TermOpen * setlocal nonumber norelativenumber + else - source ~/.vim/plugins/nerdtree.vim - source ~/.vim/plugins/whichkey.vim + source ~/.vim/plugin-confs/nerdtree.vim + source ~/.vim/plugin-confs/whichkey.vim + source ~/.vim/plugin-confs/ale.vim + source ~/.vim/plugin-confs/fzf.vim + source ~/.vim/plugin-confs/vim-closetag.vim + source ~/.vim/plugin-confs/wakatime.vim + source ~/.vim/plugin-confs/prettier.vim + source ~/.vim/plugin-confs/lightline.vim + source ~/.vim/plugin-confs/coc.vim + source ~/.vim/plugin-confs/floaterm.vim + if executable('bash-language-server') + au User lsp_setup call lsp#register_server({ + \ 'name': 'bash-language-server', + \ 'cmd': {server_info->[&shell, &shellcmdflag, 'bash-language-server start']}, + \ 'allowlist': ['sh'], + \ }) + endif endif "------------------------------------------------------------------------------ @@ -152,233 +185,9 @@ autocmd FileType man wincmd L if has("autocmd") au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif endif - -"------------------------------------------------------------------------------ -"fzf -"------------------------------------------------------------------------------ - -" This is the default extra key bindings -let g:fzf_commands_expect = 'ctrl-enter' -let g:fzf_buffers_jump = 1 -let g:fzf_tags_command = 'ctags -R' -" This is the default option: -" - Preview window on the right with 50% width -" - CTRL-/ will toggle preview window. -" - Note that this array is passed as arguments to fzf#vim#with_preview function. -" - To learn more about preview window options, see `--preview-window` section of `man fzf`. -let g:fzf_preview_window = ['right:50%', 'ctrl-/'] -let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.75 } } - -let g:fzf_action = { - \ 'ctrl-t': 'tab split', - \ 'ctrl-x': 'split', - \ 'ctrl-v': 'vsplit' } - -" An action can be a reference to a function that processes selected lines -function! s:build_quickfix_list(lines) - call setqflist(map(copy(a:lines), '{ "filename": v:val }')) - copen - cc -endfunction - -let g:fzf_action = { - \ 'ctrl-q': function('s:build_quickfix_list'), - \ 'ctrl-t': 'tab split', - \ 'ctrl-x': 'split', - \ 'ctrl-v': 'vsplit', - \ 'ctrl-n': 'next', - \} - -" Customize fzf colors to match your color scheme -" - fzf#wrap translates this to a set of `--color` options -let g:fzf_colors = -\ { 'fg': ['fg', 'Normal'], - \ 'bg': ['bg', 'Normal'], - \ 'hl': ['fg', 'Comment'], - \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], - \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], - \ 'hl+': ['fg', 'Statement'], - \ 'info': ['fg', 'PreProc'], - \ 'border': ['fg', 'Ignore'], - \ 'prompt': ['fg', 'Conditional'], - \ 'pointer': ['fg', 'Exception'], - \ 'marker': ['fg', 'Keyword'], - \ 'spinner': ['fg', 'Label'], - \ 'header': ['fg', 'Comment'] } - -" Enable per-command history -" - History files will be stored in the specified directory -" - When set, CTRL-N and CTRL-P will be bound to 'next-history' and -" 'previous-history' instead of 'down' and 'up'. -let g:fzf_history_dir = '~/.local/share/fzf-history' - -command! -bang -nargs=? -complete=dir Files - \ call fzf#vim#files(, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), 0) - -" command! -bang -nargs=? -complete=dir Files -" \ call fzf#run(fzf#wrap('files', fzf#vim#with_preview({'dir': , 'sink': 'e', 'source': 'rg --files --hidden'}), 0)) - -command! -bang -nargs=? -complete=dir AllFiles - \ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({'dir': , 'sink': 'e', 'source': 'rg --files --hidden --no-ignore'}), 0)) - - -"------------------------------------------------------------------------------ -"ale -"------------------------------------------------------------------------------ - -let g:ale_sh_shellcheck_executable = '/usr/bin/shellcheck' -let g:ale_sh_shellcheck_options = '-S info -s bash -o all -e 2250' -let g:ale_sh_shfmt_options = '-i=4 -ci -sr' -let g:ale_fix_on_save = 1 -" let g:ale_set_quickfix = 1 -let g:ale_virtualenv_dir_names = ['env'] - -let g:ale_linter_aliases = {'javascriptreact': ['css', 'javascript'], 'typescriptreact': ['css', 'javascript']} -let g:ale_linters = {'javascriptreact': ['css', 'javascript'], 'typescriptreact': ['css', 'javascript'], 'python': ['pylint','pycodestyle', 'pydocstyle'], 'sh': ['shellcheck']} -" Fix files with prettier, and then ESLint. -let g:ale_fixers = {'*': ['remove_trailing_lines', 'trim_whitespace'], 'javascript': ['prettier', 'eslint'], 'sh': ['shfmt'], 'typescript': ['eslint'], 'python': ['black']} - -"------------------------------------------------------------------------------ -"vim-closetag -"------------------------------------------------------------------------------ - -" filenames like *.xml, *.html, *.xhtml, ... -" These are the file extensions where this plugin is enabled. -let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.js,*.ts,*.jsx,*.tsx' - -" filenames like *.xml, *.xhtml, ... -" This will make the list of non-closing tags self-closing in the specified files. -" -let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.tsx,*.js,*.ts' - -" filetypes like xml, html, xhtml, ... -" These are the file types where this plugin is enabled. -" -let g:closetag_filetypes = 'html,xhtml,phtml' - -" filetypes like xml, xhtml, ... -" This will make the list of non-closing tags self-closing in the specified files. -" -let g:closetag_xhtml_filetypes = 'xhtml,jsx,tsx,js' - -" integer value [0|1] -" This will make the list of non-closing tags case-sensitive (e.g. `` will be closed while `` won't.) -" -let g:closetag_emptyTags_caseSensitive = 1 - -" Disables auto-close if not in a "valid" region (based on filetype) - -let g:closetag_regions = { - \ 'typescript.tsx': 'jsxRegion,tsxRegion', - \ 'javascript.jsx': 'jsxRegion', - \ } - -"------------------------------------------------------------------------------ -" WAKATIME -"------------------------------------------------------------------------------ - -let g:wakatime_PythonBinary = '/usr/bin/python' " (Default: 'python') -let g:wakatime_OverrideCommandPrefix = '/usr/bin/wakatime' " (Default: '') - -"------------------------------------------------------------------------------ -"PRETTIER -"------------------------------------------------------------------------------ - -packloadall "enable prettier -let g:prettier#autoformat = 1 -let g:prettier#autoformat_require_pragma = 0 -let g:prettier#exec_cmd_path = "/usr/bin/prettier" - -"------------------------------------------------------------------------------ -" Lightline -"------------------------------------------------------------------------------ - -let g:lightline = {} -" 'one', 'material', 'darcula', 'deus' -let g:lightline.colorscheme = "deus" -" let g:lightline.colorscheme = "one" -" let g:lightline.colorscheme = "darcula" -let g:lightline.component_function = { - \ 'fugitive': 'MyFugitive', - \ 'readonly': 'Readonly', - \ 'modified': 'Modified', - \ 'filename': 'Filename', - \ 'cocstatus': 'coc#status', - \} - -let g:lightline.component = { 'charhexvalue': '0x%B' } -let g:lightline.separator = { 'left': "\ue0b0", 'right': "\ue0b2" } -let g:lightline.subseparator = { 'left': "\ue0b1", 'right': "\ue0b3" } - -let g:lightline.component_expand = { - \ 'linter_checking': 'lightline#ale#checking', - \ 'linter_infos': 'lightline#ale#infos', - \ 'linter_warnings': 'lightline#ale#warnings', - \ 'linter_errors': 'lightline#ale#errors', - \ 'linter_ok': 'lightline#ale#ok', - \ } - -let g:lightline.component_type = { - \ 'linter_checking': 'right', - \ 'linter_infos': 'right', - \ 'linter_warnings': 'warning', - \ 'linter_errors': 'error', - \ 'linter_ok': 'right', - \ } - -let g:lightline.active = { - \ 'left': [ [ 'mode', 'paste' ], - \ [ 'cocstatus', 'fugitive', 'filename' ] ], - \ 'right': [ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ], - \ [ 'lineinfo' ], - \ [ 'percent' ], - \ [ 'fileformat', 'fileencoding', 'filetype'] ] } - -let g:lightline#ale#indicator_checking = "\uf110 " -let g:lightline#ale#indicator_infos = "\uf129 " -let g:lightline#ale#indicator_warnings = "\uf071 " -let g:lightline#ale#indicator_errors = "\uf05e " -let g:lightline#ale#indicator_ok = "\uf00c " - -" Use autocmd to force lightline update. -autocmd User CocStatusChange,CocDiagnosticChange call lightline#update() -function! Modified() - if &filetype == "help" - return "" - elseif &modified - return "+" - elseif &modifiable - return "" - else - return "" - endif -endfunction - -function! Readonly() - if &filetype == "help" - return "" - elseif &readonly - return "\ue0a2" - else - return "" - endif -endfunction - -function! MyFugitive() - let _ = fugitive#head() - return strlen(_) ? "\ue0a0 "._ : '' -endfunction - -function! Filename() - return ('' != Readonly() ? Readonly() . ' ' : '') . - \ ('' != expand('%:t') ? expand('%:t') : '[No Name]') . - \ ('' != Modified() ? ' ' . Modified() : '') -endfunction - "------------------------------------------------------------------------------ "COLORSCHEME "------------------------------------------------------------------------------ - set t_Co=256 if has('nvim') set termguicolors @@ -400,171 +209,16 @@ else let g:gruvbox_improved_warnings = 1 colorscheme gruvbox endif - - -"------------------------------------------------------------------------------ -"""bash language server -"------------------------------------------------------------------------------ -if executable('bash-language-server') - au User lsp_setup call lsp#register_server({ - \ 'name': 'bash-language-server', - \ 'cmd': {server_info->[&shell, &shellcmdflag, 'bash-language-server start']}, - \ 'allowlist': ['sh'], - \ }) -endif - -"------------------------------------------------------------------------------ -" NICE COC -"------------------------------------------------------------------------------ - -" Always show the signcolumn, otherwise it would shift the text each time -" diagnostics appear/become resolved. -if has("nvim-0.5.0") || has("patch-8.1.1564") - " Recently vim can merge signcolumn and number column into one - set signcolumn=number -else - set signcolumn=yes -endif -inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() -inoremap pumvisible() ? "\" : "\" -function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction -" 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()\" -nmap [g (coc-diagnostic-prev) -nmap ]g (coc-diagnostic-next) -" GoTo code navigation. -nmap gd (coc-definition) -nmap gy (coc-type-definition) -nmap gi (coc-implementation) -nmap gr (coc-references) -" 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 -" Highlight the symbol and its references when holding the cursor. -autocmd CursorHold * silent call CocActionAsync('highlight') -" Symbol renaming. -nmap rn (coc-rename) -" Formatting selected code. -xmap f (coc-format-selected) -nmap f (coc-format-selected) -augroup mygroup - autocmd! - " Setup formatexpr specified filetype(s). - autocmd FileType typescript,json,python,py,sh,bash setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder. - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') -augroup end -" Applying codeAction to the selected region. -" Example: `aap` for current paragraph -xmap a (coc-codeaction-selected) -nmap a (coc-codeaction-selected) -" Remap keys for applying codeAction to the current buffer. -nmap ac (coc-codeaction) -" Apply AutoFix to problem on the current line. -nmap qf (coc-fix-current) -" Run the Code Lens action on the current line. -nmap cl (coc-codelens-action) -" Map function and class text objects -" NOTE: Requires 'textDocument.documentSymbol' support from the language server. -xmap if (coc-funcobj-i) -omap if (coc-funcobj-i) -xmap af (coc-funcobj-a) -omap af (coc-funcobj-a) -xmap ic (coc-classobj-i) -omap ic (coc-classobj-i) -xmap ac (coc-classobj-a) -omap ac (coc-classobj-a) -" Remap and for scroll float windows/popups. -if has('nvim-0.4.0') || has('patch-8.2.0750') - nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" - inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" - vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" -endif -" Use CTRL-S for selections ranges. -" Requires 'textDocument/selectionRange' support of language server. -nmap (coc-range-select) -xmap (coc-range-select) -" Add `:Format` command to format current buffer. -command! -nargs=0 Format :call CocActionAsync('format') -" Add `:Fold` command to fold current buffer. -command! -nargs=? Fold :call CocAction('fold', ) -" Add `:OR` command for organize imports of the current buffer. -command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') -" Add (Neo)Vim's native statusline support. -" NOTE: Please see `:h coc-status` for integrations with external plugins that -" provide custom statusline: lightline.vim, vim-airline. -set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} -" Mappings for CoCList -" Show all diagnostics. -nnoremap cd :CocCommand fzf-preview.CocDiagnostics -" Manage extensions. -nnoremap ce :CocList extensions -" Show commands. -nnoremap cc :CocCommand fzf-preview.CommandPalette -" Find symbol of current document. -nnoremap co :CocOutline -" Search workspace symbols. -nnoremap cs :CocCommand fzf-preview.BufferLines -" Do default action for next item. -nnoremap cj :CocNext -" Do default action for previous item. -nnoremap ck :CocPrev -" Resume latest coc list. -nnoremap cp :CocListResume -" show references with fzf -nnoremap cr :CocCommand fzf-preview.CocReferences -" show implementations with fzf -nnoremap ci :CocCommand fzf-preview.CocImplementations -" show locationlist with fzf_preview -nnoremap cl :CocCommand fzf-preview.LocationList - -"------------------------------------------------------------------------------ -"which key -"------------------------------------------------------------------------------ - -set timeoutlen=400 - -"------------------------------------------------------------------------------ -" Floaterm -"------------------------------------------------------------------------------ - -let g:floaterm_width = 0.80 -let g:floaterm_height = 0.88 -let g:floaterm_wintype = 'float' -let g:floaterm_position = 'center' -let g:floaterm_opener = 'edit' - -let g:floaterm_autoclose = 1 -" let g:floaterm_autohide = 2 - "------------------------------------------------------------------------------ " custom commands "------------------------------------------------------------------------------ +" command! -bang -nargs=? -complete=dir Files +" \ call fzf#run(fzf#wrap('files', fzf#vim#with_preview({'dir': , 'sink': 'e', 'source': 'rg --files --hidden'}), 0)) +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), 0) + +command! -bang -nargs=? -complete=dir AllFiles + \ call fzf#run(fzf#wrap('allfiles', fzf#vim#with_preview({'dir': , 'sink': 'e', 'source': 'rg --files --hidden --no-ignore'}), 0)) command! Reload execute "source ~/.vimrc" command! Config execute ":e ~/.vimrc" @@ -572,93 +226,9 @@ command! Env execute ":Dotenv .env" command! MakeTags !ctags -R . command! Ovewrite execute ":w !sudo tee %" command! Aniwrapper execute ":FloatermNew aniwrapper -qtdoomone -D 144" - "------------------------------------------------------------------------------ "KEYBINDINGS "------------------------------------------------------------------------------ - let g:mapleader = "\" let g:maplocalleader = ',' -" imap -nmap :set paste!set paste? -nmap :! -" nmap :NERDTreeToggle -nmap :NvimTreeToggle -" nnoremap :wa:vertical botright term ++kill=term -nmap Q !!$SHELL - -" reselect visual selection after indent -vnoremap < >gv - -" open file under cursor, create if necessary -nnoremap gF :edit - -" fzf -nnoremap // :CocCommand fzf-preview.Lines -nnoremap ?? :CocCommand fzf-preview.BufferLines - -" aniwrapper/ani-cli (until i find better use for a keys) -nmap as :FloatermNew --title=aniwrapper aniwrapper -qtdoomone -D144 -nmap ad :FloatermNew --title=aniwrapper ani-cli -q720p -cd/home/sudacode/Videos/sauce -D144 -" buffers -nmap bB :CocCommand fzf-preview.AllBuffers -nmap bb :CocCommand fzf-preview.Buffers -nmap bk :bdelete -nmap bn :bnext -nmap bp :bprev -nmap :bnext -nmap :bprev -" git -nmap gc :CocCommand fzf-preview.GitLogs -nmap gf :CocCommand fzf-preview.GitFiles -if has('nvim') - nmap gg :Neogit -else - nmap gg :FloatermNew --title=lazygit --opener=vsplit --width=1.0 --height=1.0 lazygit -endif -nmap gs :CocCommand fzf-preview.GitStatus -nmap gr :CocCommand fzf-preview.CocReferences -" help/history -nmap hc :CocCommand fzf-preview.CommandPalette -nmap hk :Maps -" insert snippets -nmap isp :-1read $HOME/Templates/python.py4jw -" any jump plugin -nmap j :AnyJump -nmap n :NvimTreeToggle -" toggle/open -nmap ob :FloatermNew --title=bpytop --opener=vsplit bpytop -nmap od :FloatermNew --title=lazydocker --opener=vsplit lazydocker -nmap on :FloatermNew --title=ncmpcpp --opener=vsplit ncmpcpp -nmap oo :OverCommandLine -nmap or :FloatermNew --title=ranger --opener=vsplit ranger --cmd="cd $PWD" -" nmap ot :vertical botright ter ++kill=terminal ++close -nmap ot :FloatermNew --title=floaterm --name=vsplit-term --wintype=vsplit --position=botright --width=0.5 -" refresh nvimtree for now -nmap r :NvimTreeRefresh -" search -nmap sc :nohls -nmap sf :Files -nmap sF :AllFiles -" toggle coc outline -nmap to :CocOutline -" terminal -nmap tt :FloatermToggle vsplit-term -nmap :wa:FloatermToggle floatingterm -" for toggling/hiding the vsplit-term -tnoremap tt :FloatermToggle vsplit-term -tnoremap :FloatermToggle floatingterm -tnoremap - - -nmap ss :SessionSave -nmap sl :SessionLoad -nnoremap fh :DashboardFindHistory -" search fzf, refs, impls, defs -nmap ff :CocCommand fzf-preview.ProjectFiles -" nnoremap ff :DashboardFindFile -nnoremap tc :DashboardChangeColorscheme -nnoremap fa :DashboardFindWord -nnoremap fb :DashboardJumpMark -nnoremap cn :DashboardNewFile +source ~/.vim/keybindings.vim diff --git a/nvim/plugins/bufferline.lua b/nvim/plugin-confs/bufferline.lua similarity index 100% rename from nvim/plugins/bufferline.lua rename to nvim/plugin-confs/bufferline.lua diff --git a/nvim/plugin-confs/dashboard-art.vim b/nvim/plugin-confs/dashboard-art.vim new file mode 100644 index 0000000..4cdd9bb --- /dev/null +++ b/nvim/plugin-confs/dashboard-art.vim @@ -0,0 +1,8 @@ +let g:dashboard_custom_header = [ +\ ' ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗', +\ ' ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║', +\ ' ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║', +\ ' ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║', +\ ' ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║', +\ ' ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝', +\] diff --git a/nvim/plugins/dashboard-nvim.lua b/nvim/plugin-confs/dashboard-nvim.lua similarity index 100% rename from nvim/plugins/dashboard-nvim.lua rename to nvim/plugin-confs/dashboard-nvim.lua diff --git a/nvim/plugins/doomone.lua b/nvim/plugin-confs/doomone.lua similarity index 100% rename from nvim/plugins/doomone.lua rename to nvim/plugin-confs/doomone.lua diff --git a/nvim/plugins/dracula.lua b/nvim/plugin-confs/dracula.lua similarity index 100% rename from nvim/plugins/dracula.lua rename to nvim/plugin-confs/dracula.lua diff --git a/nvim/plugins/github-theme.lua b/nvim/plugin-confs/github-theme.lua similarity index 100% rename from nvim/plugins/github-theme.lua rename to nvim/plugin-confs/github-theme.lua diff --git a/nvim/plugin-confs/lsp-signature.lua b/nvim/plugin-confs/lsp-signature.lua new file mode 100644 index 0000000..318589f --- /dev/null +++ b/nvim/plugin-confs/lsp-signature.lua @@ -0,0 +1,56 @@ + cfg = { + debug = false, -- set to true to enable debug logging + log_path = vim.fn.stdpath("cache") .. "/lsp_signature.log", -- log dir when debug is on + -- default is ~/.cache/nvim/lsp_signature.log + verbose = false, -- show debug line number + + bind = true, -- This is mandatory, otherwise border config won't get registered. + -- If you want to hook lspsaga or other signature handler, pls set to false + doc_lines = 10, -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated); + -- set to 0 if you DO NOT want any API comments be shown + -- This setting only take effect in insert mode, it does not affect signature help in normal + -- mode, 10 by default + + floating_window = true, -- show hint in a floating window, set to false for virtual text only mode + + floating_window_above_cur_line = true, -- try to place the floating above the current line when possible Note: + -- will set to true when fully tested, set to false will use whichever side has more space + -- this setting will be helpful if you do not want the PUM and floating win overlap + + floating_window_off_x = 1, -- adjust float windows x position. + floating_window_off_y = 1, -- adjust float windows y position. + + + fix_pos = false, -- set to true, the floating window will not auto-close until finish all parameters + hint_enable = true, -- virtual hint enable + hint_prefix = "🐼 ", -- Panda for parameter + hint_scheme = "String", + hi_parameter = "LspSignatureActiveParameter", -- how your parameter will be highlight + max_height = 12, -- max height of signature floating_window, if content is more than max_height, you can scroll down + -- to view the hiding contents + max_width = 80, -- max_width of signature floating_window, line will be wrapped if exceed max_width + handler_opts = { + border = "rounded" -- double, rounded, single, shadow, none + }, + + always_trigger = false, -- sometime show signature on new line or in middle of parameter can be confusing, set it to false for #58 + + auto_close_after = nil, -- autoclose signature float win after x sec, disabled if nil. + extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","} + zindex = 200, -- by default it will be on top of all floating windows, set to <= 50 send it to bottom + + padding = '', -- character to pad on left and right of signature can be ' ', or '|' etc + + transparency = nil, -- disabled by default, allow floating win transparent value 1~100 + shadow_blend = 36, -- if you using shadow as border use this set the opacity + shadow_guibg = 'Black', -- if you using shadow as border use this set the color e.g. 'Green' or '#121315' + timer_interval = 200, -- default timer check interval set to lower value if you want to reduce latency + toggle_key = nil -- toggle signature on and off in insert mode, e.g. toggle_key = '' +} + +-- recommended: +require'lsp_signature'.setup(cfg) -- no need to specify bufnr if you don't use toggle_key + +-- You can also do this inside lsp on_attach +-- note: on_attach deprecated +-- require'lsp_signature'.on_attach(cfg, bufnr) -- no need to specify bufnr if you don't use toggle_key diff --git a/nvim/plugin-confs/lspconfig.lua b/nvim/plugin-confs/lspconfig.lua new file mode 100644 index 0000000..741cba6 --- /dev/null +++ b/nvim/plugin-confs/lspconfig.lua @@ -0,0 +1,62 @@ +local DEFAULT_SETTINGS = { + ui = { + icons = { + -- The list icon to use for installed servers. + server_installed = "◍", + -- The list icon to use for servers that are pending installation. + server_pending = "◍", + -- The list icon to use for servers that are not installed. + server_uninstalled = "◍", + }, + keymaps = { + -- Keymap to expand a server in the UI + toggle_server_expand = "", + -- Keymap to install a server + install_server = "i", + -- Keymap to reinstall/update a server + update_server = "u", + -- Keymap to update all installed servers + update_all_servers = "U", + -- Keymap to uninstall a server + uninstall_server = "X", + }, + }, + + -- The directory in which to install all servers. + install_root_dir = "~/.vim/lsp", + + pip = { + -- These args will be added to `pip install` calls. Note that setting extra args might impact intended behavior + -- and is not recommended. + -- + -- Example: { "--proxy", "https://proxyserver" } + install_args = {}, + }, + + -- Controls to which degree logs are written to the log file. It's useful to set this to vim.log.levels.DEBUG when + -- debugging issues with server installations. + log_level = vim.log.levels.INFO, + + -- Limit for the maximum amount of servers to be installed at the same time. Once this limit is reached, any further + -- servers that are requested to be installed will be put in a queue. + max_concurrent_installers = 4, +} + + +local lsp_installer = require("nvim-lsp-installer") + +-- Register a handler that will be called for each installed server when it's ready (i.e. when installation is finished +-- or if the server is already installed). +lsp_installer.on_server_ready(function(server) + local opts = {} + + -- (optional) Customize the options passed to the server + -- if server.name == "tsserver" then + -- opts.root_dir = function() ... end + -- end + + -- This setup() function will take the provided server configuration and decorate it with the necessary properties + -- before passing it onwards to lspconfig. + -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md + server:setup(DEFAULT_SETTINGS) +end) diff --git a/nvim/plugins/marks.lua b/nvim/plugin-confs/marks.lua similarity index 100% rename from nvim/plugins/marks.lua rename to nvim/plugin-confs/marks.lua diff --git a/nvim/plugins/neogit.lua b/nvim/plugin-confs/neogit.lua similarity index 100% rename from nvim/plugins/neogit.lua rename to nvim/plugin-confs/neogit.lua diff --git a/nvim/plugin-confs/null-ls.lua b/nvim/plugin-confs/null-ls.lua new file mode 100644 index 0000000..a66ff24 --- /dev/null +++ b/nvim/plugin-confs/null-ls.lua @@ -0,0 +1,86 @@ +local null_ls = require("null-ls") +local helpers = require("null-ls.helpers") + +require("null-ls").setup({ + sources = { + require("null-ls").builtins.formatting.stylua, + require("null-ls").builtins.diagnostics.eslint, + require("null-ls").builtins.completion.spell, + require("null-ls").builtins.formatting.shfmt.with({ + extra_args = { "-i", "4", "-ci", "-sr" } + }), + }, +}) + +local markdownlint = { + method = null_ls.methods.DIAGNOSTICS, + filetypes = { "markdown" }, + -- null_ls.generator creates an async source + -- that spawns the command with the given arguments and options + generator = null_ls.generator({ + command = "markdownlint", + args = { "--stdin" }, + to_stdin = true, + from_stderr = true, + -- choose an output format (raw, json, or line) + format = "line", + check_exit_code = function(code, stderr) + local success = code <= 1 + + if not success then + -- can be noisy for things that run often (e.g. diagnostics), but can + -- be useful for things that run on demand (e.g. formatting) + print(stderr) + end + + return success + end, + -- use helpers to parse the output from string matchers, + -- or parse it manually with a function + on_output = helpers.diagnostics.from_patterns({ + { + pattern = [[:(%d+):(%d+) [%w-/]+ (.*)]], + groups = { "row", "col", "message" }, + }, + { + pattern = [[:(%d+) [%w-/]+ (.*)]], + groups = { "row", "message" }, + }, + }), + }), +} + +local shellcheck = { + method = null_ls.methods.DIAGNOSTICS, + filetypes = { "sh", "bash", "zsh", "fish" }, + generator = null_ls.generator({ + command = "shellcheck", + args = { "-S", "info", "-s", "bash", "-o", "all", "-e", "2250" }, + from_stderr = true, + format = "line", + check_exit_code = function(code, stderr) + local success = code <= 1 + + if not success then + -- can be noisy for things that run often (e.g. diagnostics), but can + -- be useful for things that run on demand (e.g. formatting) + print(stderr) + end + + return success + end, + on_output = helpers.diagnostics.from_patterns({ + { + pattern = [[:(%d+):(%d+) [%w-/]+ (.*)]], + groups = { "row", "col", "message" }, + }, + { + pattern = [[:(%d+) [%w-/]+ (.*)]], + groups = { "row", "message" }, + }, + }), +}), +} + +null_ls.register(markdownlint) +null_ls.register(shellcheck) diff --git a/nvim/plugins/nvimtree.lua b/nvim/plugin-confs/nvimtree.lua similarity index 100% rename from nvim/plugins/nvimtree.lua rename to nvim/plugin-confs/nvimtree.lua diff --git a/nvim/plugin-confs/symbols-outline.lua b/nvim/plugin-confs/symbols-outline.lua new file mode 100644 index 0000000..484d266 --- /dev/null +++ b/nvim/plugin-confs/symbols-outline.lua @@ -0,0 +1,53 @@ +-- init.lua +vim.g.symbols_outline = { + highlight_hovered_item = true, + show_guides = true, + auto_preview = true, + position = 'right', + relative_width = true, + width = 35, + auto_close = false, + show_numbers = false, + show_relative_numbers = false, + show_symbol_details = true, + preview_bg_highlight = 'Pmenu', + keymaps = { -- These keymaps can be a string or a table for multiple keys + close = {"", "q"}, + goto_location = "", + focus_location = "o", + hover_symbol = "", + toggle_preview = "K", + rename_symbol = "r", + code_actions = "a", + }, + lsp_blacklist = {}, + symbol_blacklist = {}, + symbols = { + File = {icon = "", hl = "TSURI"}, + Module = {icon = "", hl = "TSNamespace"}, + Namespace = {icon = "", hl = "TSNamespace"}, + Package = {icon = "", hl = "TSNamespace"}, + Class = {icon = "𝓒", hl = "TSType"}, + Method = {icon = "ƒ", hl = "TSMethod"}, + Property = {icon = "", hl = "TSMethod"}, + Field = {icon = "", hl = "TSField"}, + Constructor = {icon = "", hl = "TSConstructor"}, + Enum = {icon = "ℰ", hl = "TSType"}, + Interface = {icon = "ﰮ", hl = "TSType"}, + Function = {icon = "", hl = "TSFunction"}, + Variable = {icon = "", hl = "TSConstant"}, + Constant = {icon = "", hl = "TSConstant"}, + String = {icon = "𝓐", hl = "TSString"}, + Number = {icon = "#", hl = "TSNumber"}, + Boolean = {icon = "⊨", hl = "TSBoolean"}, + Array = {icon = "", hl = "TSConstant"}, + Object = {icon = "⦿", hl = "TSType"}, + Key = {icon = "🔐", hl = "TSType"}, + Null = {icon = "NULL", hl = "TSType"}, + EnumMember = {icon = "", hl = "TSField"}, + Struct = {icon = "𝓢", hl = "TSType"}, + Event = {icon = "🗲", hl = "TSType"}, + Operator = {icon = "+", hl = "TSOperator"}, + TypeParameter = {icon = "𝙏", hl = "TSParameter"} + } +} diff --git a/nvim/plugins/treesitter.lua b/nvim/plugin-confs/treesitter.lua similarity index 100% rename from nvim/plugins/treesitter.lua rename to nvim/plugin-confs/treesitter.lua diff --git a/nvim/plugins/whichkey.lua b/nvim/plugin-confs/whichkey.lua similarity index 100% rename from nvim/plugins/whichkey.lua rename to nvim/plugin-confs/whichkey.lua