Getting rid of lsp-zero and re-doing lsp config. Also added Toggle Term
This commit is contained in:
parent
b90ae7b9fc
commit
daed5f0c76
@ -1,31 +1,65 @@
|
|||||||
local lsp_zero = require('lsp-zero')
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
desc = 'LSP actions',
|
||||||
|
callback = function(event)
|
||||||
|
local bufmap = function(mode, lhs, rhs)
|
||||||
|
local opts = {buffer = event.buf}
|
||||||
|
vim.keymap.set(mode, lhs, rhs, opts)
|
||||||
|
end
|
||||||
|
|
||||||
lsp_zero.on_attach(function(client, bufnr)
|
-- Trigger code completion
|
||||||
local opts = {buffer = bufnr, remap = false}
|
bufmap('i', '<C-Space>', '<C-x><C-o>')
|
||||||
-- disable semantic highlighting cause I like tree sitter's coloring better
|
-- Display documentation of the symbol under the cursor
|
||||||
client.server_capabilities.semanticTokensProvider = nil
|
bufmap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>')
|
||||||
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
-- Jump to the definition
|
||||||
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
|
bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>')
|
||||||
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
-- Jump to declaration
|
||||||
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
|
bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
|
||||||
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
|
-- Lists all the implementations for the symbol under the cursor
|
||||||
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
|
bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>')
|
||||||
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
-- Jumps to the definition of the type symbol
|
||||||
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
|
bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
|
||||||
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
-- Lists all the references
|
||||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>')
|
||||||
end)
|
-- Displays a function's signature information
|
||||||
|
bufmap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
|
||||||
|
-- Renames all references to the symbol under the cursor
|
||||||
|
bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>')
|
||||||
|
-- Format current file
|
||||||
|
bufmap('n', '<F3>', '<cmd>lua vim.lsp.buf.format()<cr>')
|
||||||
|
-- Selects a code action available at the current cursor position
|
||||||
|
bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>')
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
|
||||||
require('mason').setup({})
|
require('mason').setup({})
|
||||||
require('mason-lspconfig').setup({
|
require('mason-lspconfig').setup({
|
||||||
ensure_installed = {'lua_ls', 'jedi_language_server', 'rust_analyzer', 'clangd' },
|
ensure_installed = {'lua_ls', 'jedi_language_server', 'rust_analyzer', 'clangd' },
|
||||||
handlers = {
|
handlers = {
|
||||||
lsp_zero.default_setup,
|
require('lspconfig').clangd.setup({
|
||||||
lua_ls = function()
|
filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto","hpp"},
|
||||||
local lua_opts = lsp_zero.nvim_lua_ls()
|
capabilities = capabilities,
|
||||||
require('lspconfig').lua_ls.setup(lua_opts)
|
}),
|
||||||
end,
|
require('lspconfig').rust_analyzer.setup({
|
||||||
}
|
capabilities = capabilities,
|
||||||
|
cmd = {
|
||||||
|
"rustup", "run", "stable", "rust-analyzer",
|
||||||
|
}
|
||||||
|
|
||||||
|
}),
|
||||||
|
require('lspconfig').jedi_language_server.setup{
|
||||||
|
capabilities = capabilities,
|
||||||
|
},
|
||||||
|
require('lspconfig').lua_ls.setup{
|
||||||
|
capabilities = capabilities,
|
||||||
|
-- settings = {
|
||||||
|
-- workspace = {
|
||||||
|
-- environmentPath = "./venv/bin/python",
|
||||||
|
-- }
|
||||||
|
-- }
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
@ -37,7 +71,6 @@ cmp.setup({
|
|||||||
{name = 'nvim_lsp'},
|
{name = 'nvim_lsp'},
|
||||||
{name = 'nvim_lua'},
|
{name = 'nvim_lua'},
|
||||||
},
|
},
|
||||||
formatting = lsp_zero.cmp_format(),
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||||
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||||
|
@ -49,11 +49,10 @@ require("lazy").setup({
|
|||||||
cmd = "Neoconf"
|
cmd = "Neoconf"
|
||||||
},
|
},
|
||||||
"folke/neodev.nvim",
|
"folke/neodev.nvim",
|
||||||
-- {'akinsho/toggleterm.nvim', version = "*", config = true},
|
{'akinsho/toggleterm.nvim', version = "*", config = true},
|
||||||
{"danymat/neogen", dependencies = "nvim-treesitter/nvim-treesitter", config = true},
|
{"danymat/neogen", dependencies = "nvim-treesitter/nvim-treesitter", config = true},
|
||||||
{'williamboman/mason.nvim'},
|
{'williamboman/mason.nvim'},
|
||||||
{'williamboman/mason-lspconfig.nvim'},
|
{'williamboman/mason-lspconfig.nvim'},
|
||||||
{'VonHeikemen/lsp-zero.nvim', branch = 'v3.x'},
|
|
||||||
{'neovim/nvim-lspconfig'},
|
{'neovim/nvim-lspconfig'},
|
||||||
{'hrsh7th/cmp-nvim-lsp'},
|
{'hrsh7th/cmp-nvim-lsp'},
|
||||||
{'hrsh7th/nvim-cmp'},
|
{'hrsh7th/nvim-cmp'},
|
||||||
|
Loading…
Reference in New Issue
Block a user