let plug_install = 0 let autoload_plug_path = stdpath('config') . '/autoload/plug.vim' if !filereadable(autoload_plug_path) silent exe '!curl -fL --create-dirs -o ' . autoload_plug_path . \ ' https://raw.github.com/junegunn/vim-plug/master/plug.vim' execute 'source ' . fnameescape(autoload_plug_path) let plug_install = 1 endif unlet autoload_plug_path call plug#begin('~/.config/nvim/plugins') " Code development helpers {{{ Plug 'neovim/nvim-lspconfig' Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' Plug 'wellle/context.vim' Plug 'dbeniamine/cheat.sh-vim' " }}} " Files switch, jump and grep-like tools {{{ Plug 'preservim/nerdtree' | Plug 'Xuyuanp/nerdtree-git-plugin' Plug 'junegunn/fzf.vim' Plug 'liuchengxu/vista.vim' Plug 'inside/vim-search-pulse' Plug 'mhinz/vim-startify' " }}} " Git integration {{{ Plug 'mhinz/vim-signify' " Mark edited lines - faster gitgutter " }}} " Colorschemes {{{ Plug 'jaredgorski/spacecamp' Plug 'vim-airline/vim-airline' | Plug 'vim-airline/vim-airline-themes' " }}} " Other plugins (external tools, etc) {{{ Plug 'junegunn/goyo.vim' Plug 'jez/vim-superman' "vman application Plug 'glacambre/firenvim' " }}} call plug#end() if plug_install PlugInstall --sync endif unlet plug_install set number set clipboard+=unnamedplus set noshowmode set laststatus=2 set background=dark colorscheme spacecamp highlight MatchParen ctermfg=yellow ctermbg=none cterm=NONE set listchars=tab:▸\ ,trail:¬ set list hi clear SpellBad hi SpellBad cterm=underline set tabstop=4 set shiftwidth=4 set softtabstop=4 set expandtab " Ctags {{{ if isdirectory($HOME . '/.vim/tags') == 0 :silent !mkdir -p ~/.vim/tags > /dev/null 2>&1 endif let g:gutentags_cache_dir='~/.vim/tags' "let g:gutentags_ctags_extra_args=['--fields=+l'] let mapleader = "\\" inoremap jj inoremap jk inoremap :w :w nnoremap 2 :set tabstop=2 softtabstop=2 shiftwidth=2 nnoremap 4 :set tabstop=4 softtabstop=4 shiftwidth=4 nnoremap 8 :set tabstop=8 softtabstop=8 shiftwidth=8 nnoremap :nohlsearch let g:UltiSnipsExpandTrigger="" let g:UltiSnipsJumpForwardTrigger="" let g:UltiSnipsJumpBackwardTrigger="" " TextEdit might fail if hidden is not set. set hidden " Some servers have issues with backup files, see #649. set nobackup set nowritebackup " Give more space for displaying messages. set cmdheight=2 " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable " delays and poor user experience. set updatetime=300 " Don't pass messages to |ins-completion-menu|. set shortmess+=c " Always show the signcolumn, otherwise it would shift the text each time " diagnostics appear/become resolved. if has("patch-8.1.1564") " Recently vim can merge signcolumn and number column into one set signcolumn=number else set signcolumn=yes endif set colorcolumn=80 " yoink configuration "nmap yp (YoinkPostPasteSwapBack) "nmap yn (YoinkPostPasteSwapForward) "nmap p (YoinkPaste_p) "nmap P (YoinkPaste_P) " Mapping to NERDTree nnoremap t :NERDTreeToggle let NERDTreeIgnore=['\.vim$', '\~$', '\.pyc$'] nnoremap ff :FZF! nnoremap fl :Lines! nnoremap fb :Buffers inoremap fs :Snippets! nnoremap fa :Rg! " Disable context.vim on json files let g:context_filetype_blacklist = ["json"] match Error /\s\+$\|DU\cPA/ function! FindAlternate() let l:ext = 'h' let l:curr_ext = expand('%:e') if (l:curr_ext == 'c') let l:ext = 'h' elseif (l:curr_ext == 'cpp') let l:ext = 'h' elseif (l:curr_ext == 'h') let l:ext = 'c' elseif (l:curr_ext == 'hpp') let l:ext = 'cpp' endif let l:file = expand('%:t:r') . '.' . l:ext :exec 'find ' . l:file endfunction nnoremap :call FindAlternate() setglobal virtualedit=block setglobal shiftround let g:vim_search_pulse_mode = 'pattern' let g:vim_search_pulse_duration = 400 let g:airline_theme = 'minimalist' let g:airline_powerline_fonts = 1 let g:airline_stl_path_style = 'short' let g:airline_highlighting_cache = 1 let g:startify_custom_header = '' " Completion configuration for native neovim + nvim-lspconfig lua << EOF local lspconfig = require'lspconfig' lspconfig.ccls.setup { init_options = { compilationDatabaseDirectory = "."; index = { threads = 0; }; clang = { excludeArgs = { "-frounding-math"} ; }; } } EOF lua << EOF require'lspconfig'.pyls.setup{} EOF lua << EOF require'lspconfig'.cmake.setup{} EOF lua << EOF require'lspconfig'.rls.setup { settings = { rust = { unstable_features = true, build_on_save = false, all_features = true, }, }, } EOF lua << EOF local nvim_lsp = require('lspconfig') -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end --Enable completion triggered by buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') -- Mappings. local opts = { noremap=true, silent=true } -- See `:help vim.lsp.*` for documentation on any of the below functions buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts) buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts) buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) buf_set_keymap('n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) buf_set_keymap('n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) buf_set_keymap('n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) end -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches local servers = { "pyls", "rls", "cmake", 'ccls' } for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup { on_attach = on_attach } end EOF