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', 'lua vim.lsp.buf.declaration()', opts) buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts) buf_set_keymap('n', 'gt', 'lua vim.lsp.buf.type_definition()', opts) buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts) buf_set_keymap('n', 'ra', 'lua vim.lsp.buf.code_action()', opts) buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) buf_set_keymap('n', 'rd', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) buf_set_keymap('n', 'rh', 'lua vim.lsp.buf.hover()', opts) buf_set_keymap('n', 'rs', 'lua vim.lsp.buf.signature_help()', opts) buf_set_keymap('n', 'rk', 'lua vim.lsp.diagnostic.goto_prev()', opts) buf_set_keymap('n', 'rj', 'lua vim.lsp.diagnostic.goto_next()', opts) buf_set_keymap('n', 'rl', 'lua vim.lsp.diagnostic.set_loclist()', opts) -- Set some keybinds conditional on server capabilities if client.resolved_capabilities.document_formatting then buf_set_keymap("n", "f", "lua vim.lsp.buf.formatting()", opts) elseif client.resolved_capabilities.document_range_formatting then buf_set_keymap("n", "f", "lua vim.lsp.buf.range_formatting()", 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! * autocmd CursorHold lua vim.lsp.buf.document_highlight() autocmd CursorMoved 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