2021-08-22 15:23:16 -04:00
|
|
|
syntax on
|
|
|
|
filetype on
|
|
|
|
filetype plugin on
|
|
|
|
set encoding=utf-8
|
|
|
|
set clipboard=unnamedplus
|
|
|
|
set nu rnu
|
|
|
|
set smartindent
|
|
|
|
set nocp
|
|
|
|
set bo=all
|
2022-02-06 12:48:48 -05:00
|
|
|
set mouse=a
|
2021-08-22 15:23:16 -04:00
|
|
|
colorscheme torte
|
|
|
|
set list
|
|
|
|
set listchars=tab:*·,lead:·,trail:~,extends:>,precedes:<
|
2021-10-12 16:06:35 -04:00
|
|
|
filetype indent off
|
2021-08-22 15:23:16 -04:00
|
|
|
hi SignColumn ctermbg=233
|
2021-12-06 18:06:04 -05:00
|
|
|
hi DiffChange ctermbg=17
|
|
|
|
hi DiffDelete ctermbg=52 ctermfg=15
|
|
|
|
hi DiffAdd ctermbg=22
|
|
|
|
hi DiffText ctermbg=166 ctermfg=15
|
|
|
|
hi Folded ctermbg=233 ctermfg=247
|
|
|
|
hi FoldColumn ctermbg=233 ctermfg=247
|
2021-08-22 15:23:16 -04:00
|
|
|
|
2021-12-06 18:06:04 -05:00
|
|
|
let mapleader = " "
|
|
|
|
let maplocalleader = ","
|
|
|
|
|
2022-01-17 17:30:15 -05:00
|
|
|
nnoremap <silent> <F12> <cmd>set et<cr><cmd>set ts=4<cr><cmd>set sw=4<cr>
|
|
|
|
nnoremap <silent> <F11> <cmd>set noet<cr>
|
2021-12-06 18:06:04 -05:00
|
|
|
nnoremap <silent> <F2> <cmd>ToggleDiagOff<cr>:Gdiffsplit<cr>
|
|
|
|
nnoremap <silent> <F5> <cmd>ToggleDiag<cr>
|
2022-01-17 17:30:15 -05:00
|
|
|
nnoremap <silent> <F6> <cmd>%!expand -t4<cr><cmd>%!sed 's/[ \t]*$//'<cr>
|
|
|
|
nnoremap <silent> <F7> <cmd>%!unexpand -t4<cr><cmd>%!sed 's/[ \t]*$//'<cr>
|
2022-02-06 12:48:48 -05:00
|
|
|
nnoremap <silent> <F8> <cmd>TagbarToggle<CR>
|
|
|
|
nnoremap <silent> <C-n> <cmd>NERDTreeToggle<CR>
|
2021-08-22 15:23:16 -04:00
|
|
|
|
2021-12-06 18:06:04 -05:00
|
|
|
nnoremap <silent> <leader>ev <cmd>tabnew $MYVIMRC<cr>
|
|
|
|
nnoremap <silent> <leader>sv <cmd>source $MYVIMRC<cr>
|
2021-12-14 11:53:50 -05:00
|
|
|
nnoremap <C-s> :%s//gc<left><left><left>
|
2021-12-06 18:06:04 -05:00
|
|
|
nnoremap <silent> <C-w>t <cmd>tabnew<cr>
|
2022-03-12 12:49:08 -05:00
|
|
|
|
2021-12-06 18:06:04 -05:00
|
|
|
nnoremap dL 0D
|
2022-03-12 12:49:08 -05:00
|
|
|
nnoremap - ddp
|
|
|
|
nnoremap _ ddkP
|
2021-08-22 15:23:16 -04:00
|
|
|
|
2021-10-28 16:35:00 -04:00
|
|
|
" auto quote
|
2021-08-22 15:23:16 -04:00
|
|
|
vnoremap <leader>" <esc>a"<esc>`<i"<esc>`>
|
|
|
|
nnoremap H 0
|
|
|
|
nnoremap L $
|
2021-10-12 16:06:35 -04:00
|
|
|
|
2022-03-12 12:49:08 -05:00
|
|
|
augroup python
|
|
|
|
autocmd FileType python :iabbrev <buffer> frompdb from pdb import set_trace; set_trace()
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
augroup nerdtree
|
|
|
|
" Exit Vim if NERDTree is the only window remaining in the only tab.
|
|
|
|
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
|
|
|
" Close the tab if NERDTree is the only window remaining in it.
|
|
|
|
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
let g:airline_theme = "powerlineish"
|
|
|
|
let g:airline#extensions#tabline#enabled = 1
|
|
|
|
let g:airline_powerline_fonts = 1
|
|
|
|
let g:airline#extensions#nerdtree_statusline = 1
|
|
|
|
|
2021-08-22 15:23:16 -04:00
|
|
|
call plug#begin('~/.config/nvim/plugged')
|
|
|
|
|
|
|
|
Plug 'vim-airline/vim-airline'
|
|
|
|
Plug 'vim-airline/vim-airline-themes'
|
|
|
|
|
|
|
|
Plug 'scrooloose/nerdtree'
|
|
|
|
Plug 'scrooloose/nerdcommenter'
|
|
|
|
|
|
|
|
" LSP config
|
|
|
|
Plug 'neovim/nvim-lspconfig'
|
|
|
|
" *auto* completion
|
|
|
|
Plug 'hrsh7th/nvim-compe'
|
|
|
|
|
|
|
|
Plug 'tpope/vim-fugitive'
|
|
|
|
|
2021-10-28 16:35:00 -04:00
|
|
|
Plug 'drmingdrmer/xptemplate'
|
|
|
|
|
2021-12-06 18:06:04 -05:00
|
|
|
Plug 'WhoIsSethDaniel/toggle-lsp-diagnostics.nvim'
|
|
|
|
|
2022-02-06 12:48:48 -05:00
|
|
|
Plug 'preservim/tagbar'
|
|
|
|
|
2022-03-12 12:49:08 -05:00
|
|
|
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
2022-02-06 12:48:48 -05:00
|
|
|
Plug 'junegunn/fzf.vim'
|
2021-08-22 15:23:16 -04:00
|
|
|
|
2022-03-12 12:49:08 -05:00
|
|
|
Plug 'tpope/vim-sleuth'
|
2021-08-22 16:22:04 -04:00
|
|
|
|
2022-03-12 12:49:08 -05:00
|
|
|
call plug#end()
|
2021-08-22 15:23:16 -04:00
|
|
|
|
|
|
|
lua << EOF
|
|
|
|
--- nvim-compe
|
|
|
|
require'compe'.setup {
|
|
|
|
enabled = true;
|
|
|
|
autocomplete = true;
|
|
|
|
debug = false;
|
|
|
|
min_length = 1;
|
|
|
|
preselect = 'enable';
|
|
|
|
throttle_time = 80;
|
|
|
|
source_timeout = 200;
|
|
|
|
incomplete_delay = 400;
|
|
|
|
max_abbr_width = 100;
|
|
|
|
max_kind_width = 100;
|
|
|
|
max_menu_width = 100;
|
|
|
|
documentation = true;
|
|
|
|
|
|
|
|
source = {
|
|
|
|
path = true;
|
|
|
|
nvim_lsp = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
--- IMPORTANT
|
|
|
|
vim.api.nvim_set_keymap('i', '<cr>', 'compe#confirm("<cr>")', { expr = true })
|
|
|
|
|
2021-11-27 08:28:43 -05:00
|
|
|
local common_bindings = function(client, bufnr)
|
2021-08-22 15:23:16 -04:00
|
|
|
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
2022-02-06 12:48:48 -05:00
|
|
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
|
|
|
|
|
|
|
local opts = { noremap=true, silent=true }
|
2021-08-22 15:23:16 -04:00
|
|
|
|
|
|
|
--Enable completion triggered by <c-x><c-o>
|
|
|
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
2022-02-06 12:48:48 -05:00
|
|
|
|
|
|
|
buf_set_keymap('n', '<C-[>', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
2021-08-22 15:23:16 -04:00
|
|
|
end
|
|
|
|
|
2021-11-27 08:28:43 -05:00
|
|
|
local default_formatting = function(client, bufnr)
|
|
|
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
|
|
|
|
|
|
|
local opts = { noremap=true, silent=true }
|
|
|
|
|
|
|
|
buf_set_keymap('n', '<leader>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
local default_attach = function(client, bufnr)
|
|
|
|
common_bindings(client, bufnr)
|
|
|
|
default_formatting(client, bufnr)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2021-11-27 08:52:52 -05:00
|
|
|
local setup = function(lsp, on_attach, settings)
|
2021-11-27 08:28:43 -05:00
|
|
|
local nvim_lsp = require('lspconfig')
|
|
|
|
|
2021-08-22 15:23:16 -04:00
|
|
|
nvim_lsp[lsp].setup {
|
|
|
|
on_attach = on_attach,
|
|
|
|
flags = {
|
|
|
|
debounce_text_changes = 150,
|
2021-11-27 08:28:43 -05:00
|
|
|
},
|
2021-11-27 08:52:52 -05:00
|
|
|
settings=settings
|
2021-08-22 15:23:16 -04:00
|
|
|
}
|
|
|
|
end
|
2021-11-27 08:28:43 -05:00
|
|
|
|
|
|
|
-- Use a loop to conveniently call 'setup' on multiple servers and
|
|
|
|
-- map buffer local keybindings when the language server attaches
|
2022-02-06 12:48:48 -05:00
|
|
|
local servers = { 'clangd', 'rls', 'tsserver', 'jedi_language_server' }
|
2021-11-27 08:28:43 -05:00
|
|
|
for _, lsp in ipairs(servers) do
|
|
|
|
setup(lsp, default_attach)
|
|
|
|
end
|
2021-08-22 15:23:16 -04:00
|
|
|
EOF
|
|
|
|
|
|
|
|
" auto close scratch buffer (preview window)
|
|
|
|
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
|
2021-10-28 16:35:00 -04:00
|
|
|
|
|
|
|
" xptemplate (snippets) config
|
|
|
|
let g:xptemplate_vars = "SPcmd=&SParg="
|