feat: vim lsp setup
This commit is contained in:
parent
671533f47c
commit
784a2b72ed
2 changed files with 65 additions and 4 deletions
|
@ -4,11 +4,19 @@ vim.g.loaded_netrwPlugin = 1
|
|||
vim.g.mapleader = " "
|
||||
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.softtabstop = 4
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.expandtab = true
|
||||
|
||||
vim.cmd.colorscheme "catppuccin"
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.scrolloff = 8
|
||||
|
||||
-- Custom bindings
|
||||
vim.cmd.colorscheme "catppuccin-mocha"
|
||||
|
||||
-- Custom bindings for buffer navigation
|
||||
vim.keymap.set("n", "<leader>n", "<cmd>bn<CR>", { noremap = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>p", "<cmd>bp<CR>", { noremap = true, silent = true })
|
||||
|
||||
|
@ -21,9 +29,60 @@ require("lualine").setup{}
|
|||
-- Telescope (anything search)
|
||||
vim.keymap.set("n", "<leader>b", "<cmd>Telescope buffers<CR>", { noremap = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>f", "<cmd>Telescope find_files<CR>", { noremap = true, silent = true })
|
||||
vim.keymap.set("n", "<leader>g", "<cmd>Telescope git_files<CR>", { noremap = true, silent = true })
|
||||
|
||||
-- Tree (file manager)
|
||||
require("nvim-tree").setup()
|
||||
vim.keymap.set("n", "<leader>t", "<cmd>NvimTreeToggle<CR>", { noremap = true, silent = true })
|
||||
|
||||
-- lspconfig (LSPs)
|
||||
vim.lsp.enable("nil")
|
||||
vim.lsp.enable("lua_ls")
|
||||
vim.lsp.enable("nil_ls")
|
||||
vim.lsp.enable("pyright")
|
||||
vim.lsp.enable("rust-analyzer")
|
||||
vim.lsp.enable("rust_analyzer")
|
||||
|
||||
vim.keymap.set("n", "<leader>o", vim.lsp.buf.format)
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
desc = 'LSP actions',
|
||||
callback = function()
|
||||
local bufmap = function(mode, lhs, rhs)
|
||||
local opts = {buffer = true}
|
||||
vim.keymap.set(mode, lhs, rhs, opts)
|
||||
end
|
||||
|
||||
-- Displays hover information about the symbol under the cursor
|
||||
bufmap('n', 'K', vim.lsp.buf.hover)
|
||||
|
||||
-- Jump to the definition
|
||||
bufmap('n', 'gd', vim.lsp.buf.definition)
|
||||
|
||||
-- Jump to declaration
|
||||
bufmap('n', 'gD', vim.lsp.buf.declaration)
|
||||
|
||||
-- Lists all the implementations for the symbol under the cursor
|
||||
bufmap('n', 'gi', vim.lsp.buf.implementation)
|
||||
|
||||
-- Jumps to the definition of the type symbol
|
||||
bufmap('n', 'go', vim.lsp.buf.type_definition)
|
||||
|
||||
-- Lists all the references
|
||||
bufmap('n', 'gr', vim.lsp.buf.references)
|
||||
|
||||
-- Displays a function's signature information
|
||||
bufmap('n', '<C-k>', vim.lsp.buf.signature_help)
|
||||
|
||||
-- Renames all references to the symbol under the cursor
|
||||
bufmap('n', '<leader>R', vim.lsp.buf.rename)
|
||||
|
||||
-- Show diagnostics in a floating window
|
||||
bufmap('n', 'gl', vim.diagnostic.open_float)
|
||||
|
||||
-- Move to the previous diagnostic
|
||||
bufmap('n', '[d', vim.diagnostic.goto_prev)
|
||||
|
||||
-- Move to the next diagnostic
|
||||
bufmap('n', ']d', vim.diagnostic.goto_next)
|
||||
end
|
||||
})
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ in
|
|||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = with pkgs; [
|
||||
lua-language-server
|
||||
nil
|
||||
pyright
|
||||
rust-analyzer
|
||||
|
@ -29,6 +30,7 @@ in
|
|||
bufferline-nvim
|
||||
catppuccin-nvim
|
||||
lualine-nvim
|
||||
nvim-tree-lua
|
||||
nvim-lspconfig
|
||||
telescope-nvim
|
||||
nvim-web-devicons
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue