aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2026-10-02 17:18:58 +0200
committerMartin Fischer <martin@push-f.com>2026-10-10 20:09:13 +0200
commit193b76b4a7cdb8566df40da1423d087710ba4b84 (patch)
treeee5382debac7c3cc1f50ab217ca2bcd41c898b98
parentb43108d65fd97ad1c0b3721818388ccee01b52ae (diff)
feat(workstation): set up LSP with nvim
-rw-r--r--nixos/profiles/workstation/graphical.nix4
-rw-r--r--nixos/profiles/workstation/pkgs/nvim.nix4
-rw-r--r--user/nvim/init.lua42
3 files changed, 50 insertions, 0 deletions
diff --git a/nixos/profiles/workstation/graphical.nix b/nixos/profiles/workstation/graphical.nix
index 90f99b3..696efa0 100644
--- a/nixos/profiles/workstation/graphical.nix
+++ b/nixos/profiles/workstation/graphical.nix
@@ -49,6 +49,10 @@
[[ "$(tty)" == /dev/tty1 ]] && exec niri-session -l
'';
+ fonts.packages = with pkgs; [
+ nerd-fonts.symbols-only
+ ];
+
environment.systemPackages = with pkgs; [
wmenu
i3bar-river
diff --git a/nixos/profiles/workstation/pkgs/nvim.nix b/nixos/profiles/workstation/pkgs/nvim.nix
index 0961b4d..988da94 100644
--- a/nixos/profiles/workstation/pkgs/nvim.nix
+++ b/nixos/profiles/workstation/pkgs/nvim.nix
@@ -19,5 +19,9 @@ pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped {
svelte
typescript
]))
+
+ # for LSP
+ nvim-lspconfig
+ blink-cmp
];
}
diff --git a/user/nvim/init.lua b/user/nvim/init.lua
index 282d086..a05a7f9 100644
--- a/user/nvim/init.lua
+++ b/user/nvim/init.lua
@@ -22,6 +22,41 @@ pick.setup({ source = { show = pick.default_show } })
-- Reuse Neovim's popup-menu selection color for mini.pick's selected item.
vim.api.nvim_set_hl(0, 'MiniPickMatchCurrent', { link = 'PmenuSel' })
+-- Enable language servers when they are available (for example, from a nix shell).
+local language_servers = {
+ { name = 'rust_analyzer', cmd = { 'rust-analyzer' } },
+ { name = 'pyright', cmd = { 'pyright-langserver', '--stdio' } },
+ { name = 'ts_ls', cmd = { 'typescript-language-server', '--stdio' } },
+ { name = 'gopls', cmd = { 'gopls' } },
+ { name = 'nixd', cmd = { 'nixd' } },
+ { name = 'svelte', cmd = { 'svelteserver', '--stdio' } },
+}
+
+for _, server in ipairs(language_servers) do
+ local command = vim.fn.exepath(server.cmd[1])
+ if command ~= '' then
+ server.cmd[1] = command
+ vim.lsp.config(server.name, { cmd = server.cmd })
+ vim.lsp.enable(server.name)
+ end
+end
+
+require('blink.cmp').setup({
+ keymap = {
+ preset = 'default',
+ ['<CR>'] = { 'accept', 'fallback' },
+ },
+ sources = {
+ -- Only show completion items provided by an attached LSP. This disables
+ -- blink.cmp's default buffer/path/snippet sources, which otherwise trigger
+ -- completions in plain text and Markdown files.
+ default = { 'lsp' },
+ },
+ completion = {
+ documentation = { auto_show = true },
+ },
+})
+
-- Keyboard shortcuts
-- Clear search highlighting with Escape.
@@ -31,6 +66,13 @@ vim.keymap.set('n', '<C-p>', function()
pick.builtin.files()
end, { desc = 'Pick files' })
+vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {
+ desc = 'LSP: Go to definition',
+})
+vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, {
+ desc = 'LSP: Go to declaration',
+})
+
-- Disable netrw's directory browser; directory arguments are handled below with MiniPick.
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1