296 lines
8.4 KiB
VimL
296 lines
8.4 KiB
VimL
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'
|
|
Plug 'puremourning/vimspector'
|
|
Plug 'derekwyatt/vim-fswitch'
|
|
Plug 'nvim-lua/completion-nvim'
|
|
" }}}
|
|
|
|
" Files switch, jump and grep-like tools {{{
|
|
Plug 'preservim/nerdtree' | Plug 'Xuyuanp/nerdtree-git-plugin'
|
|
Plug 'junegunn/fzf' | Plug 'junegunn/fzf.vim'
|
|
Plug 'liuchengxu/vista.vim'
|
|
Plug 'inside/vim-search-pulse'
|
|
Plug 'mhinz/vim-startify'
|
|
Plug 'wellle/targets.vim'
|
|
" }}}
|
|
|
|
" Git integration {{{
|
|
Plug 'mhinz/vim-signify' " Mark edited lines - faster gitgutter
|
|
" }}}
|
|
|
|
" Syntax for random filetypes {{{
|
|
Plug 'masukomi/vim-markdown-folding'
|
|
"Plug 'weirongxu/plantuml-previewer.vim' |
|
|
Plug 'aklt/plantuml-syntax'
|
|
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
|
|
" }}}
|
|
|
|
" Other plugins (external tools, etc) {{{
|
|
Plug 'vimwiki/vimwiki'
|
|
Plug 'MortenStabenau/matlab-vim'
|
|
Plug 'junegunn/goyo.vim'
|
|
Plug 'jez/vim-superman' "vman application
|
|
Plug 'glacambre/firenvim'
|
|
Plug 'JMcKiern/vim-shoot'
|
|
" }}}
|
|
|
|
" Filetype syntax {{{
|
|
Plug 'plasticboy/vim-markdown'
|
|
Plug 'kergoth/vim-bitbake' " Bitbake templates and syntax
|
|
Plug 'pboettch/vim-cmake-syntax'
|
|
Plug 'aklt/plantuml-syntax'
|
|
" }}}
|
|
|
|
" Colorschemes {{{
|
|
Plug 'jaredgorski/spacecamp'
|
|
Plug 'lifepillar/vim-gruvbox8'
|
|
Plug 'dylanaraps/wal'
|
|
Plug 'vim-airline/vim-airline' | Plug 'vim-airline/vim-airline-themes'
|
|
" }}}
|
|
"
|
|
call plug#end()
|
|
|
|
if plug_install
|
|
PlugInstall --sync
|
|
endif
|
|
unlet plug_install
|
|
|
|
set number
|
|
set clipboard+=unnamedplus
|
|
|
|
set noshowmode
|
|
set laststatus=2
|
|
|
|
set colorcolumn=80
|
|
|
|
set background=dark
|
|
colorscheme wal
|
|
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
|
|
|
|
set ignorecase
|
|
set smartcase
|
|
|
|
set gdefault
|
|
|
|
" space one line, home,end globally increase/decrease
|
|
nnoremap <Home> zc
|
|
nnoremap <End> zo
|
|
|
|
" TODO define cache dir and conf dir, use them everywhere
|
|
" Ctags {{{
|
|
if isdirectory($HOME . '/.cache/nvim/tags') == 0
|
|
:silent !mkdir -p ~/.cache/nvim/tags > /dev/null 2>&1
|
|
endif
|
|
let g:gutentags_cache_dir='~/.cache/nvim/tags'
|
|
"let g:gutentags_ctags_extra_args=['--fields=+l']
|
|
|
|
if isdirectory($HOME . '/.cache/nvim/undo') == 0
|
|
:silent !mkdir -p ~/.cache/nvim/undo > /dev/null 2>&1
|
|
endif
|
|
set undodir=~/.cache/nvim/undo/
|
|
set undofile
|
|
|
|
let mapleader = "\\"
|
|
|
|
inoremap jj <ESC>
|
|
inoremap jk <ESC>
|
|
inoremap :w<CR> <Esc>:w<CR>
|
|
|
|
" Reselect visual block after incrementing/decrementing
|
|
vnoremap <c-a> <c-a>gv
|
|
vnoremap <c-x> <c-x>gv
|
|
|
|
nnoremap <leader>2 <esc>:set tabstop=2 softtabstop=2 shiftwidth=2<cr>
|
|
nnoremap <leader>4 <esc>:set tabstop=4 softtabstop=4 shiftwidth=4<cr>
|
|
nnoremap <leader>8 <esc>:set tabstop=8 softtabstop=8 shiftwidth=8<cr>
|
|
|
|
nnoremap <leader><space> :nohlsearch<cr>
|
|
|
|
let g:UltiSnipsExpandTrigger="<c-s>"
|
|
let g:UltiSnipsJumpForwardTrigger="<c-n>"
|
|
let g:UltiSnipsJumpBackwardTrigger="<c-p>"
|
|
|
|
" 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
|
|
set shortmess-=F
|
|
|
|
" 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 wildmode=longest,list,full
|
|
|
|
" yoink configuration
|
|
"nmap <leader>yp <plug>(YoinkPostPasteSwapBack)
|
|
"nmap <leader>yn <plug>(YoinkPostPasteSwapForward)
|
|
"nmap p <plug>(YoinkPaste_p)
|
|
"nmap P <plug>(YoinkPaste_P)
|
|
|
|
" Mapping to NERDTree
|
|
nnoremap <leader>t :NERDTreeToggle<CR>
|
|
let NERDTreeIgnore=['\.vim$', '\~$', '\.pyc$']
|
|
|
|
nnoremap <leader>f :FZF!<CR>
|
|
nnoremap <leader>l :Lines!<CR>
|
|
nnoremap <leader>b :Buffers<CR>
|
|
inoremap <leader>s <ESC>:Snippets!<CR>
|
|
nnoremap <leader>a :Rg! <C-R><C-W><CR>
|
|
|
|
" Disable context.vim on json files
|
|
let g:context_filetype_blacklist = ["json"]
|
|
|
|
match Error /\s\+$\|DU\cPA/
|
|
|
|
nnoremap <F6> :silent FSHere<CR>
|
|
|
|
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 = ''
|
|
|
|
packadd termdebug
|
|
|
|
let g:vimwiki_list = [{'path': '~/vimwiki/',
|
|
\ 'syntax': 'markdown', 'ext': '.md'}]
|
|
|
|
" 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 <c-x><c-o>
|
|
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', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
|
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
|
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
|
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
|
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
|
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
|
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
|
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
|
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
|
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
|
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
|
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
|
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
|
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
|
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
|
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
|
require'completion'.on_attach()
|
|
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
|
|
"
|
|
" lua require'lspconfig'.pyls.setup{on_attach=require'completion'.on_attach}
|
|
" lua require'lspconfig'.ccls.setup{on_attach=require'completion'.on_attach}
|
|
" lua require'lspconfig'.cmake.setup{on_attach=require'completion'.on_attach}
|
|
" lua require'lspconfig'.rls.setup{on_attach=require'completion'.on_attach}
|
|
"
|
|
" Set completeopt to have a better completion experience
|
|
set completeopt=menuone,noinsert,noselect
|
|
let g:completion_enable_snippet = 'UltiSnips'
|