" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim call plug#begin() " The default plugin directory will be as follows: " - Vim (Linux/macOS): '~/.vim/plugged' " - Vim (Windows): '~/vimfiles/plugged' " - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged' " You can specify a custom plugin directory by passing it as the argument " - e.g. `call plug#begin('~/.vim/plugged')` " - Avoid using standard Vim directory names like 'plugin' " Make sure you use single quotes " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align " Plug 'junegunn/vim-easy-align' " Any valid git URL is allowed " Plug 'https://github.com/junegunn/vim-github-dashboard.git' " Multiple Plug commands can be written in a single line using | separators " Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' " On-demand loading " Plug 'tpope/vim-fireplace', { 'for': 'clojure' } " Using a non-default branch " Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' } " Using a tagged release; wildcard allowed (requires git 1.9.2 or above) " Plug 'fatih/vim-go', { 'tag': '*' } " Plugin options " Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' } " Plugin outside ~/.vim/plugged with post-update hook Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } Plug 'majutsushi/tagbar' Plug 'vim-scripts/bufexplorer.zip' Plug 'scrooloose/nerdtree' " Plug 'junegunn/fzf' Plug 'junegunn/fzf.vim' Plug 'tpope/vim-fugitive' Plug 'krisajenkins/vim-pipe' Plug 'krisajenkins/vim-postgresql-syntax' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'gilgigilgil/anderson.vim' Plug 'dbeniamine/cheat.sh-vim' Plug 'jiangmiao/auto-pairs' Plug 'voldikss/vim-floaterm' Plug 'lifepillar/vim-solarized8' Plug 'ludovicchabant/vim-gutentags' Plug 'skywind3000/gutentags_plus' Plug 'skywind3000/vim-preview' Plug 'ryanoasis/vim-devicons' Plug 'ziglang/zig.vim' Plug 'w0ng/vim-hybrid' Plug 'NLKNguyen/papercolor-theme' Plug 'prabirshrestha/vim-lsp' Plug 'prabirshrestha/asyncomplete.vim' Plug 'prabirshrestha/asyncomplete-lsp.vim' Plug 'prabirshrestha/asyncomplete-buffer.vim' Plug 'mattn/vim-lsp-settings' Plug 'purescript-contrib/purescript-vim' "Plug 'jiangmiao/auto-pairs' Plug 'VArtzy/auto-pairs-v9' Plug 'sainnhe/sonokai' Plug 'octol/vim-cpp-enhanced-highlight' Plug 'unblevable/quick-scope' Plug 'derekwyatt/vim-scala' Plug 'ocaml/vim-ocaml' Plug 'gleam-lang/gleam.vim' " Unmanaged plugin (manually installed and updated) " Plug '~/my-prototype-plugin' " Initialize plugin system " - Automatically executes `filetype plugin indent on` and `syntax enable`. call plug#end() " You can revert the settings after the call like so: " filetype indent off " Disable file-type-specific indentation " syntax off " Disable syntax highlighting filetype plugin indent on " required hi Cursor guifg=black guibg=yellow hi Search guifg=black guibg=yellow set laststatus=2 " Always display the statusline in all windows "set showtabline=2 " Always display the tabline, even if there is only one tab set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline) set nobackup set nowrap set nu set guicursor=a:blinkon0 set guicursor+=a:block-Cursor set tabstop=2 set shiftwidth=2 set expandtab set ignorecase set history=50 set ruler set showcmd set incsearch set autoindent set hlsearch set modeline set encoding=utf-8 set fileencodings=utf-8,gb18030,big5 set termguicolors hi Directory guifg=#FF0000 ctermfg=red hi Comment ctermfg=green autocmd FileType sql let b:vimpipe_filetype="postgresql" autocmd FileType sql let b:vimpipe_command="docker exec -i postgres psql -Upostgres weapp" "autocmd FileType sql let b:vimpipe_command="docker exec -i postgres16 psql -Upostgres weapp" if !exists('g:airline_symbols') let g:airline_symbols = {} endif let g:airline_left_sep = '' let g:airline_left_alt_sep = '' let g:airline_right_sep = '' let g:airline_right_alt_sep = '' let g:airline_symbols.branch = '' let g:airline_symbols.readonly = '' let g:airline_symbols.linenr = '☰' let g:airline_symbols.maxlinenr = '' let g:airline_theme='base16_oceanicnext' colorscheme anderson " Floater nnoremap :FloatermNew tnoremap :FloatermNew nnoremap :FloatermPrev tnoremap :FloatermPrev nnoremap :FloatermNext tnoremap :FloatermNext nnoremap :FloatermToggle tnoremap :FloatermToggle let g:floaterm_position = 'bottomleft' let g:floaterm_width = 1.0 let g:floaterm_shell = "/bin/bash -l" augroup qs_colors autocmd! autocmd ColorScheme * highlight QuickScopePrimary guifg='#afff5f' gui=underline ctermfg=155 cterm=underline autocmd ColorScheme * highlight QuickScopeSecondary guifg='#5fffff' gui=underline ctermfg=81 cterm=underline augroup END nmap q (QuickScopeToggle) xmap q (QuickScopeToggle) inoremap j ((pumvisible())?("\"):("j")) inoremap k ((pumvisible())?("\"):("k")) " gutentags let g:gutentags_project_root = ['.git'] let g:gutentags_ctags_tagfile = 'tags' let g:gutentags_ctags_executable = '/usr/bin/ctags' let g:gutentags_modules = ['ctags','gtags_cscope'] let g:gutentags_cache_dir = expand('~/.cache/tags') let g:gutentags_auto_add_gtags_cscope = 0 let g:gutentags_ctags_extra_args = ['--fields=+niazS','--extra=+q'] let g:gutentags_ctags_extra_args += ['--c++-kinds=+px'] let g:gutentags_ctags_extra_args += ['--c-kinds=+px'] let g:gutentags_ctags_extra_args += ['--output-format=e-ctags'] let g:gutentags_plus_switch = 1 let g:gutentags_trace = 0 let gutentags_exclude_filetypes = ['.scala', '.sbt', '.zig', '.less', '.wxml'] autocmd FileType qf nnoremap l :PreviewQuickfix autocmd FileType qf nnoremap L :PreviewClose noremap :PreviewClose noremap :PreviewTag noremap :PreviewSignature! inoremap :PreviewTag inoremap :PreviewSignature! noremap :PreviewScroll -1 noremap :PreviewScroll +1 inoremap :PreviewScroll -1 inoremap :PreviewScroll +1 if executable('clangd') augroup lsp_clangd autocmd! autocmd User lsp_setup call lsp#register_server({ \ 'name': 'clangd', \ 'cmd': {server_info->['clangd']}, \ 'whitelist': ['c', 'cpp', 'objc', 'objcpp'], \ }) autocmd FileType c setlocal omnifunc=lsp#complete autocmd FileType cpp setlocal omnifunc=lsp#complete autocmd FileType objc setlocal omnifunc=lsp#complete autocmd FileType objcpp setlocal omnifunc=lsp#complete augroup end endif if executable('gleam') au User lsp_setup call lsp#register_server({ \ 'name': 'gleam', \ 'cmd': {server_info->['gleam lsp']}, \ 'root_uri':{server_info->lsp#utils#path_to_uri( \ lsp#utils#find_nearest_parent_file_directory( \ lsp#utils#get_buffer_path(), \ ['gleam.toml', '.git'], \ ))}, \ 'whitelist': ['gleam'], \ }) autocmd FileType gleam setlocal omnifunc=lsp#complete endif function! s:on_lsp_buffer_enabled() abort setlocal omnifunc=lsp#complete setlocal signcolumn=yes "if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif nmap gd (lsp-definition) nmap gs (lsp-document-symbol-search) nmap gS (lsp-workspace-symbol-search) nmap gr (lsp-references) nmap gi (lsp-implementation) nmap gt (lsp-type-definition) nmap rn (lsp-rename) nmap [g (lsp-previous-diagnostic) nmap ]g (lsp-next-diagnostic) nmap K (lsp-hover) nnoremap lsp#scroll(+4) nnoremap lsp#scroll(-4) let g:lsp_format_sync_timeout = 1000 autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync') " refer to doc to add more commands endfunction " Toggling diagnostics and virtual text {{{ autocmd BufEnter * let b:my_lsp_diagnostics_enabled = 1 function! s:ToggleLSPDiagnostics() " source: https://github.com/prabirshrestha/vim-lsp/issues/1312 if !exists('b:my_lsp_diagnostics_enabled') " Ensure the buffer variable is defined let b:my_lsp_diagnostics_enabled = 1 endif if b:my_lsp_diagnostics_enabled == 1 call lsp#disable_diagnostics_for_buffer() let b:my_lsp_diagnostics_enabled = 0 echo "LSP Diagnostics : OFF" else call lsp#enable_diagnostics_for_buffer() let b:my_lsp_diagnostics_enabled = 1 echo "LSP Diagnostics : ON" endif endfunction command ToggleLSPDiagnostics call s:ToggleLSPDiagnostics() " nnoremap :MyToggleLSPDiagnosticszz " Toggling diagnostic and virtual text }}} augroup lsp_install au! " call s:on_lsp_buffer_enabled only for languages that has the server registered. autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() augroup END function! SortLinesByLength() range " Save the selected range let start_line = a:firstline let end_line = a:lastline " Create a list of lines with their lengths let lines_with_length = [] for lnum in range(start_line, end_line) let line_text = getline(lnum) call add(lines_with_length, {'text': line_text, 'length': strlen(line_text)}) endfor " Sort the list by line length let sorted_lines = sort(lines_with_length, {a, b -> a['length'] - b['length']}) " Replace the selected lines with the sorted lines let current_line = start_line for line_info in sorted_lines call setline(current_line, line_info['text']) let current_line += 1 endfor endfunction let g:lsp_diagnostics_virtual_text_enabled = 0 let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] call asyncomplete#register_source(asyncomplete#sources#buffer#get_source_options({ \ 'name': 'buffer', \ 'allowlist': ['*'], \ 'blocklist': ['go'], \ 'completor': function('asyncomplete#sources#buffer#completor'), \ 'config': { \ 'max_buffer_size': 5000000, \ }, \ })) "set foldmethod=expr " \ foldexpr=lsp#ui#vim#folding#foldexpr() " \ foldtext=lsp#ui#vim#folding#foldtext()