dotfiles/dot_config/nvim/init.vim
2021-10-13 18:45:52 -05:00

169 lines
4.3 KiB
VimL

call plug#begin(stdpath('data') . '/plugged')
Plug 'vim-airline/vim-airline'
exe 'source' (stdpath('config') . '/airline.vim')
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
" exe 'source' (stdpath('config') . '/coc.vim')
Plug 'preservim/nerdtree'
exe 'source' (stdpath('config') . '/nerdtree.vim')
" Plug 'ctrlpvim/ctrlp.vim'
let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""'
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/nvim-compe'
Plug 'FStarLang/VimFStar', {'for': 'fstar'}
Plug 'LnL7/vim-nix'
" Plug 'ashinkarov/nvim-agda'
Plug 'derekelkins/agda-vim'
Plug 'evanleck/vim-svelte', {'branch': 'main'}
Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
Plug 'sheerun/vim-polyglot'
Plug 'tomasiser/vim-code-dark'
Plug 'editorconfig/editorconfig-vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'wakatime/vim-wakatime'
Plug 'andweeb/presence.nvim'
call plug#end()
let g:go_fmt_command = 'goimports'
let g:vim_markdown_new_list_item_indent = 2
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_toml_frontmatter = 1
" General config
colorscheme codedark
set splitright
set number relativenumber
set cursorline
set hidden
set modeline
set modelines=5
set tabstop=4
set shiftwidth=4
set expandtab
set formatoptions+=t
set colorcolumn=80
set textwidth=80
syntax on
filetype on
filetype plugin indent on
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu | endif
autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
augroup END
" Binds
let mapleader = ";"
let maplocalleader = ";"
nnoremap T :vsplit<BAR>vertical resize 54<BAR>terminal<CR>i
imap kj <Esc>
nmap <F8> :TagbarToggle<CR>
" Plugin-related configs
let g:go_fmt_command = "goimports"
" LSP
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent> <space>k <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
nnoremap <silent> <space>j <cmd>lua vim.lsp.diagnostic.goto_next()<CR>
lua << EOF
vim.o.completeopt = "menuone,noselect"
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 = false;
source = {
path = true;
buffer = true;
calc = true;
vsnip = true;
nvim_lsp = true;
nvim_lua = true;
spell = true;
tags = true;
snippets_nvim = true;
treesitter = true;
};
}
local t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
local check_back_space = function()
local col = vim.fn.col('.') - 1
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
return true
else
return false
end
end
-- Use (s-)tab to:
--- move to prev/next item in completion menuone
--- jump to prev/next snippet's placeholder
_G.tab_complete = function()
if vim.fn.pumvisible() == 1 then
return t "<C-n>"
elseif vim.fn.call("vsnip#available", {1}) == 1 then
return t "<Plug>(vsnip-expand-or-jump)"
elseif check_back_space() then
return t "<Tab>"
else
return vim.fn['compe#complete']()
end
end
_G.s_tab_complete = function()
if vim.fn.pumvisible() == 1 then
return t "<C-p>"
elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
return t "<Plug>(vsnip-jump-prev)"
else
-- If <S-Tab> is not working in your terminal, change it to <C-h>
return t "<S-Tab>"
end
end
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
require'lspconfig'.rust_analyzer.setup{}
require'lspconfig'.pyright.setup{}
EOF
" vim: set sw=2 :