feat(neovim): add lsp, autoformat and completions
This commit is contained in:
parent
e3a513794a
commit
7723267fd5
2 changed files with 39 additions and 1 deletions
|
@ -6,14 +6,19 @@
|
||||||
extraLuaConfig = builtins.readFile ./init.lua;
|
extraLuaConfig = builtins.readFile ./init.lua;
|
||||||
|
|
||||||
extraPackages = with pkgs; [
|
extraPackages = with pkgs; [
|
||||||
(lua5_1.withPackages (ps: with ps; [ luarocks ]))
|
lua5_1
|
||||||
|
nixfmt-rfc-style
|
||||||
tree-sitter
|
tree-sitter
|
||||||
];
|
];
|
||||||
|
|
||||||
plugins = with pkgs.vimPlugins; [
|
plugins = with pkgs.vimPlugins; [
|
||||||
barbar-nvim
|
barbar-nvim
|
||||||
catppuccin-nvim
|
catppuccin-nvim
|
||||||
|
cmp-nvim-lsp
|
||||||
|
lsp-format-nvim
|
||||||
lualine-nvim
|
lualine-nvim
|
||||||
|
nvim-cmp
|
||||||
|
nvim-lspconfig
|
||||||
nvim-treesitter.withAllGrammars
|
nvim-treesitter.withAllGrammars
|
||||||
nvim-web-devicons # for lualine
|
nvim-web-devicons # for lualine
|
||||||
];
|
];
|
||||||
|
|
|
@ -36,6 +36,11 @@ vim.opt.inccommand = "split"
|
||||||
-- highlight the line the cursor is on
|
-- highlight the line the cursor is on
|
||||||
vim.opt.cursorline = true
|
vim.opt.cursorline = true
|
||||||
|
|
||||||
|
-- set default tab size
|
||||||
|
vim.opt.shiftwidth = 2
|
||||||
|
vim.opt.tabstop = 2
|
||||||
|
vim.opt.expandtab = true
|
||||||
|
|
||||||
-- sync os clipboard and neovim
|
-- sync os clipboard and neovim
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
vim.opt.clipboard = "unnamedplus"
|
vim.opt.clipboard = "unnamedplus"
|
||||||
|
@ -78,3 +83,31 @@ require("lualine").setup({
|
||||||
},
|
},
|
||||||
extensions = { "trouble" },
|
extensions = { "trouble" },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local cmp = require("cmp")
|
||||||
|
local cmp_caps = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
cmp.setup({
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
-- accept completion with enter
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
|
}),
|
||||||
|
sources = {
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
local lspformat = require("lsp-format")
|
||||||
|
lspformat.setup({})
|
||||||
|
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
lspconfig.nixd.setup({
|
||||||
|
on_attach = lspformat.on_attach,
|
||||||
|
capabilities = cmp_caps,
|
||||||
|
settings = {
|
||||||
|
["nixd"] = {
|
||||||
|
formatting = {
|
||||||
|
command = { "nixfmt" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue