Added readme and a lot of rust config
This commit is contained in:
+126
-3
@@ -13,9 +13,6 @@ Plug 'google/vim-glaive'
|
||||
" Go development
|
||||
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
|
||||
|
||||
" Better python syntax
|
||||
Plug 'vim-python/python-syntax'
|
||||
|
||||
" Formatter for Python
|
||||
Plug 'psf/black'
|
||||
|
||||
@@ -32,6 +29,20 @@ Plug 'SirVer/ultisnips'
|
||||
Plug 'lervag/vimtex'
|
||||
Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' }
|
||||
|
||||
" LSP Config
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
Plug 'nvim-lua/lsp_extensions.nvim'
|
||||
Plug 'hrsh7th/cmp-nvim-lsp', {'branch': 'main'}
|
||||
Plug 'hrsh7th/cmp-buffer', {'branch': 'main'}
|
||||
Plug 'hrsh7th/cmp-path', {'branch': 'main'}
|
||||
Plug 'hrsh7th/nvim-cmp', {'branch': 'main'}
|
||||
Plug 'ray-x/lsp_signature.nvim'
|
||||
|
||||
" More syntax
|
||||
Plug 'rust-lang/rust.vim'
|
||||
Plug 'plasticboy/vim-markdown'
|
||||
Plug 'vim-python/python-syntax'
|
||||
|
||||
call plug#end()
|
||||
|
||||
set autowrite
|
||||
@@ -70,6 +81,118 @@ let g:python_highlight_all = 1
|
||||
let g:vimtex_view_method = 'zathura'
|
||||
let g:vimtex_quickfix_mode=0
|
||||
|
||||
" LSP configuration
|
||||
lua << END
|
||||
local cmp = require'cmp'
|
||||
|
||||
local lspconfig = require'lspconfig'
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED by nvim-cmp. get rid of it once we can
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
-- Tab immediately completes. C-n/C-p to select.
|
||||
['<Tab>'] = cmp.mapping.confirm({ select = true })
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
-- TODO: currently snippets from lsp end up getting prioritized -- stop that!
|
||||
{ name = 'nvim_lsp' },
|
||||
}, {
|
||||
{ name = 'path' },
|
||||
}),
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
},
|
||||
})
|
||||
|
||||
-- Enable completing paths in :
|
||||
cmp.setup.cmdline(':', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
})
|
||||
})
|
||||
|
||||
-- Setup 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
|
||||
|
||||
--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>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>r', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>a', '<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.diagnostic.open_float()<CR>', opts)
|
||||
buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.set_loclist()<CR>', opts)
|
||||
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
||||
|
||||
-- Get signatures (and _only_ signatures) when in argument lists.
|
||||
require "lsp_signature".on_attach({
|
||||
doc_lines = 0,
|
||||
handler_opts = {
|
||||
border = "none"
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
lspconfig.rust_analyzer.setup {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
cargo = {
|
||||
allFeatures = true,
|
||||
},
|
||||
completion = {
|
||||
postfix = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
virtual_text = true,
|
||||
signs = true,
|
||||
update_in_insert = true,
|
||||
}
|
||||
)
|
||||
END
|
||||
|
||||
let g:rustfmt_autosave = 1
|
||||
let g:rustfmt_emit_files = 1
|
||||
let g:rustfmt_fail_silently = 0
|
||||
|
||||
set completeopt=menuone,noinsert,noselect
|
||||
|
||||
" Proper search
|
||||
set incsearch
|
||||
set ignorecase
|
||||
set smartcase
|
||||
set gdefault
|
||||
|
||||
set cc=80
|
||||
set tw=792034
|
||||
set background=dark
|
||||
|
||||
Reference in New Issue
Block a user