Modified neovim for better Rust auto complete
This commit is contained in:
parent
cd9a19d75a
commit
45aeddb69b
|
@ -3,6 +3,7 @@ local lspconfig = require 'lspconfig'
|
|||
-- local on_attach = function(client)
|
||||
-- require 'completion'.on_attach(client)
|
||||
-- end
|
||||
vim.lsp.inlay_hint.enable(true)
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
|
@ -64,7 +65,7 @@ lspconfig.lua_ls.setup {
|
|||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { 'vim', 'require' },
|
||||
globals = { 'vim', 'require', 'select_opts' },
|
||||
},
|
||||
format = {
|
||||
-- Put format options here
|
||||
|
@ -109,26 +110,3 @@ lspconfig.pylsp.setup {
|
|||
},
|
||||
}
|
||||
|
||||
-- RUST
|
||||
lspconfig.rust_analyzer.setup({
|
||||
-- on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
imports = {
|
||||
granularity = {
|
||||
group = "module",
|
||||
},
|
||||
prefix = "self",
|
||||
},
|
||||
cargo = {
|
||||
buildScripts = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
procMacro = {
|
||||
enable = true
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -22,9 +22,13 @@ cmp.setup({
|
|||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
-- Allows selection with tab and shift-tab
|
||||
['<S-Tab>'] = cmp.mapping.select_prev_item(select_opts),
|
||||
['<Tab>'] = cmp.mapping.select_next_item(select_opts),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
-- ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
|
@ -100,7 +104,3 @@ require('lspconfig')['pylsp'].setup {
|
|||
capabilities = capabilities
|
||||
}
|
||||
|
||||
-- RUST
|
||||
require('lspconfig')['rust_analyzer'].setup {
|
||||
capabilities = capabilities
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<leader>a",
|
||||
function()
|
||||
vim.cmd.RustLsp('codeAction') -- supports rust-analyzer's grouping
|
||||
-- or vim.lsp.buf.codeAction() if you don't want grouping.
|
||||
end,
|
||||
{ silent = true, buffer = bufnr }
|
||||
)
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"K", -- Override Neovim's built-in hover keymap with rustaceanvim's hover actions
|
||||
function()
|
||||
vim.cmd.RustLsp({'hover', 'actions'})
|
||||
end,
|
||||
{ silent = true, buffer = bufnr }
|
||||
)
|
|
@ -36,6 +36,12 @@ local plugins = {
|
|||
{ 'hrsh7th/cmp-buffer' },
|
||||
{ 'hrsh7th/cmp-path' },
|
||||
{ 'hrsh7th/cmp-cmdline' },
|
||||
-- Rust cmp & lsp
|
||||
{
|
||||
'mrcjkb/rustaceanvim',
|
||||
version = '^5', -- Recommended
|
||||
lazy = false, -- This plugin is already lazy
|
||||
},
|
||||
|
||||
-- -- For luasnip users
|
||||
{
|
||||
|
@ -49,8 +55,7 @@ local plugins = {
|
|||
'nvim-lua/plenary.nvim',
|
||||
},
|
||||
{ 'echasnovski/mini.nvim', version = '*' },
|
||||
-- Rust & vim auxiliary packages
|
||||
{ "simrat39/rust-tools.nvim" },
|
||||
-- vim auxiliary packages
|
||||
{
|
||||
"lervag/vimtex",
|
||||
lazy = false, -- we don't want to lazy load VimTeX
|
||||
|
@ -151,7 +156,7 @@ local plugins = {
|
|||
{ 'nvim-telescope/telescope.nvim' },
|
||||
},
|
||||
},
|
||||
'jinh0/eyeliner.nvim',
|
||||
{ 'jinh0/eyeliner.nvim' },
|
||||
{
|
||||
"anuvyklack/windows.nvim",
|
||||
dependencies = {
|
||||
|
@ -193,6 +198,8 @@ local plugins = {
|
|||
{
|
||||
'sakhnik/nvim-gdb',
|
||||
},
|
||||
-- Rust debug
|
||||
{ 'mfussenegger/nvim-dap' },
|
||||
-- Compiler
|
||||
{ -- This plugin
|
||||
"Zeioth/compiler.nvim",
|
||||
|
|
|
@ -206,6 +206,15 @@ then
|
|||
-- optionally enable 24-bit colour
|
||||
-- vim.opt.termguicolors = true
|
||||
|
||||
-- Folds
|
||||
vim.opt.foldmethod = "expr"
|
||||
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||
vim.opt.foldcolumn = "0"
|
||||
vim.opt.foldtext = ""
|
||||
vim.opt.foldlevel = 99
|
||||
vim.opt.foldlevelstart = 1
|
||||
vim.opt.foldnestmax = 4
|
||||
|
||||
vim.opt.scrolloff = 8
|
||||
vim.opt.signcolumn = "yes"
|
||||
vim.opt.isfname:append("@-@")
|
||||
|
|
Loading…
Reference in New Issue