103 lines
3.6 KiB
VimL
103 lines
3.6 KiB
VimL
cnoremap w!! w !sudo tee > /dev/null %
|
|
|
|
autocmd vimenter * ++nested colorscheme gruvbox
|
|
|
|
set guifont=Fira\ Code:h11
|
|
|
|
let g:airline#extensions#tabline#enabled = 1
|
|
let g:airline#extensions#tabline#fnamemod = ':t'
|
|
let g:airline_powerline_fonts = 1
|
|
|
|
set hidden
|
|
set nobackup
|
|
set nowritebackup
|
|
set cmdheight=2
|
|
set updatetime=300
|
|
set shortmess+=c
|
|
set signcolumn=yes
|
|
|
|
lua << EOF
|
|
-- Mostly stolen from https://github.com/breuerfelix/nixos/blob/e0c83e66e821d407efae3e998b8eb70b50f9f5e3/shell/vim/lsp.lua
|
|
local nvim_lsp = require('lspconfig')
|
|
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
|
|
|
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
|
|
-- Mappings.
|
|
local opts = { noremap = true, silent = true }
|
|
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', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
|
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
|
|
|
buf_set_keymap('n', '<leader>ra', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
|
buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
|
buf_set_keymap('n', '<leader>rd', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
|
buf_set_keymap('n', '<leader>rh', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
|
buf_set_keymap('n', '<leader>rs', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
|
buf_set_keymap('n', '<leader>rk', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
|
buf_set_keymap('n', '<leader>rj', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
|
buf_set_keymap('n', '<leader>rl', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
|
|
|
-- Set some keybinds conditional on server capabilities
|
|
if client.resolved_capabilities.document_formatting then
|
|
buf_set_keymap("n", "<leader>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
|
elseif client.resolved_capabilities.document_range_formatting then
|
|
buf_set_keymap("n", "<leader>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
|
|
end
|
|
|
|
-- Set autocommands conditional on server_capabilities
|
|
if client.resolved_capabilities.document_highlight then
|
|
vim.api.nvim_exec([[
|
|
hi LspReferenceRead cterm=bold ctermbg=red guibg=LightGrey
|
|
hi LspReferenceText cterm=bold ctermbg=red guibg=LightGrey
|
|
hi LspReferenceWrite cterm=bold ctermbg=red guibg=LightGrey
|
|
augroup lsp_document_highlight
|
|
autocmd! * <buffer>
|
|
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
|
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
|
augroup END
|
|
]], false)
|
|
end
|
|
end
|
|
|
|
nvim_lsp['pyright'].setup { on_attach = on_attach }
|
|
nvim_lsp['clangd'].setup {
|
|
on_attach = on_attach,
|
|
cmd = { "{{CLANGDPATH}}" }
|
|
}
|
|
nvim_lsp['java_language_server'].setup {
|
|
on_attach = on_attach,
|
|
cmd = { "{{JLSPATH}}" }
|
|
}
|
|
nvim_lsp['rust_analyzer'].setup { on_attach = on_attach }
|
|
nvim_lsp['rnix'].setup { on_attach = on_attach }
|
|
|
|
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;
|
|
buffer = true;
|
|
calc = true;
|
|
nvim_lsp = true;
|
|
nvim_lua = true;
|
|
vsnip = false;
|
|
};
|
|
}
|
|
EOF
|