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)
|
||||
local opts = {buffer = bufnr, remap = false}
|
||||
-- disable semantic highlighting cause I like tree sitter's coloring better
|
||||
client.server_capabilities.semanticTokensProvider = nil
|
||||
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
||||
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
|
||||
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
|
||||
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
|
||||
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
|
||||
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
end)
|
||||
-- Trigger code completion
|
||||
bufmap('i', '<C-Space>', '<C-x><C-o>')
|
||||
-- Display documentation of the symbol under the cursor
|
||||
bufmap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>')
|
||||
-- Jump to the definition
|
||||
bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>')
|
||||
-- Jump to declaration
|
||||
bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
|
||||
-- Lists all the implementations for the symbol under the cursor
|
||||
bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>')
|
||||
-- Jumps to the definition of the type symbol
|
||||
bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
|
||||
-- Lists all the references
|
||||
bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>')
|
||||
-- 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-lspconfig').setup({
|
||||
ensure_installed = {'lua_ls', 'jedi_language_server', 'rust_analyzer', 'clangd' },
|
||||
handlers = {
|
||||
lsp_zero.default_setup,
|
||||
lua_ls = function()
|
||||
local lua_opts = lsp_zero.nvim_lua_ls()
|
||||
require('lspconfig').lua_ls.setup(lua_opts)
|
||||
end,
|
||||
require('lspconfig').clangd.setup({
|
||||
filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto","hpp"},
|
||||
capabilities = capabilities,
|
||||
}),
|
||||
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')
|
||||
@ -37,7 +71,6 @@ cmp.setup({
|
||||
{name = 'nvim_lsp'},
|
||||
{name = 'nvim_lua'},
|
||||
},
|
||||
formatting = lsp_zero.cmp_format(),
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
|
@ -49,11 +49,10 @@ require("lazy").setup({
|
||||
cmd = "Neoconf"
|
||||
},
|
||||
"folke/neodev.nvim",
|
||||
-- {'akinsho/toggleterm.nvim', version = "*", config = true},
|
||||
{'akinsho/toggleterm.nvim', version = "*", config = true},
|
||||
{"danymat/neogen", dependencies = "nvim-treesitter/nvim-treesitter", config = true},
|
||||
{'williamboman/mason.nvim'},
|
||||
{'williamboman/mason-lspconfig.nvim'},
|
||||
{'VonHeikemen/lsp-zero.nvim', branch = 'v3.x'},
|
||||
{'neovim/nvim-lspconfig'},
|
||||
{'hrsh7th/cmp-nvim-lsp'},
|
||||
{'hrsh7th/nvim-cmp'},
|
||||
|
Loading…
Reference in New Issue
Block a user