Skip to content

Commit

Permalink
users/frontear: add lsp-format to neovim
Browse files Browse the repository at this point in the history
This can be invoked automatically on save, or via `:Format`. I don't have an exhaustive set of preferences of how I want to format things, but I do need to be careful so that it doesn't override my personal opinions for formatting.
  • Loading branch information
Frontear committed Dec 3, 2024
1 parent 48a1533 commit 85b5bb7
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions users/frontear/home/neovim/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
lib,
pkgs,
...
}:
Expand Down Expand Up @@ -57,6 +58,7 @@
bins = with pkgs; [
basedpyright
clang-tools
jdt-language-server
nixd
rust-analyzer
zls
Expand All @@ -70,6 +72,8 @@
luasnip
nvim-cmp

lsp-format-nvim

nvim-lspconfig
];

Expand All @@ -91,28 +95,27 @@
}),
})
local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local lsp_format = require("lsp-format")
lspconfig.basedpyright.setup({
capabilities = capabilities,
})
lsp_format.setup {}
lspconfig.clangd.setup({
capabilities = capabilities,
})
lspconfig.nixd.setup({
capabilities = capabilities,
})
lspconfig.rust_analyzer.setup({
capabilities = capabilities,
})
lspconfig.zls.setup({
capabilities = capabilities,
})
local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local on_attach = lsp_format.on_attach
${lib.concatStringsSep "\n" (map (lsp: ''
lspconfig.${lsp}.setup({
capabilities = capabilities,
on_attach = on_attach
})
'') [
"basedpyright"
"clangd"
"jdtls"
"nixd"
"rust_analyzer"
"zls"
])}
'';
}
{
Expand Down

0 comments on commit 85b5bb7

Please sign in to comment.