try to add lsp support
This commit is contained in:
parent
ac7c134e02
commit
d371faf31e
5 changed files with 258 additions and 14 deletions
74
common/nvim/lsp_autocmd.lua
Normal file
74
common/nvim/lsp_autocmd.lua
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
function(event)
|
||||||
|
-- NOTE: Remember that lua is a real programming language, and as such it is possible
|
||||||
|
-- to define small helper and utility functions so you don't have to repeat yourself
|
||||||
|
-- many times.
|
||||||
|
--
|
||||||
|
-- In this case, we create a function that lets us more easily define mappings specific
|
||||||
|
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
||||||
|
local map = function(keys, func, desc)
|
||||||
|
vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Jump to the definition of the word under your cursor.
|
||||||
|
-- This is where a variable was first declared, or where a function is defined, etc.
|
||||||
|
-- To jump back, press <C-T>.
|
||||||
|
map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
|
||||||
|
|
||||||
|
-- Find references for the word under your cursor.
|
||||||
|
map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
|
||||||
|
|
||||||
|
-- Jump to the implementation of the word under your cursor.
|
||||||
|
-- Useful when your language has ways of declaring types without an actual implementation.
|
||||||
|
map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
|
||||||
|
|
||||||
|
-- Jump to the type of the word under your cursor.
|
||||||
|
-- Useful when you're not sure what type a variable is and you want to see
|
||||||
|
-- the definition of its *type*, not where it was *defined*.
|
||||||
|
map("<leader>D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition")
|
||||||
|
|
||||||
|
-- Fuzzy find all the symbols in your current document.
|
||||||
|
-- Symbols are things like variables, functions, types, etc.
|
||||||
|
map("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
|
||||||
|
|
||||||
|
-- Fuzzy find all the symbols in your current workspace
|
||||||
|
-- Similar to document symbols, except searches over your whole project.
|
||||||
|
map(
|
||||||
|
"<leader>ws",
|
||||||
|
require("telescope.builtin").lsp_dynamic_workspace_symbols,
|
||||||
|
"[W]orkspace [S]ymbols"
|
||||||
|
)
|
||||||
|
|
||||||
|
-- Rename the variable under your cursor
|
||||||
|
-- Most Language Servers support renaming across files, etc.
|
||||||
|
map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
|
||||||
|
|
||||||
|
-- Execute a code action, usually your cursor needs to be on top of an error
|
||||||
|
-- or a suggestion from your LSP for this to activate.
|
||||||
|
map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction")
|
||||||
|
|
||||||
|
-- Opens a popup that displays documentation about the word under your cursor
|
||||||
|
-- See `:help K` for why this keymap
|
||||||
|
map("K", vim.lsp.buf.hover, "Hover Documentation")
|
||||||
|
|
||||||
|
-- WARN: This is not Goto Definition, this is Goto Declaration.
|
||||||
|
-- For example, in C this would take you to the header
|
||||||
|
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
|
||||||
|
|
||||||
|
-- The following two autocommands are used to highlight references of the
|
||||||
|
-- word under your cursor when your cursor rests there for a little while.
|
||||||
|
-- See `:help CursorHold` for information about when this is executed
|
||||||
|
--
|
||||||
|
-- When you move your cursor, the highlights will be cleared (the second autocommand).
|
||||||
|
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
||||||
|
if client and client.server_capabilities.documentHighlightProvider then
|
||||||
|
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||||
|
buffer = event.buf,
|
||||||
|
callback = vim.lsp.buf.document_highlight,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||||
|
buffer = event.buf,
|
||||||
|
callback = vim.lsp.buf.clear_references,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -5,16 +5,188 @@
|
||||||
# needed for the nvim config, neovim itself is a system package already
|
# needed for the nvim config, neovim itself is a system package already
|
||||||
ripgrep
|
ripgrep
|
||||||
];
|
];
|
||||||
programs.neovim = {
|
# programs.neovim = {
|
||||||
|
# enable = true;
|
||||||
|
# defaultEditor = true;
|
||||||
|
#
|
||||||
|
# viAlias = true;
|
||||||
|
# vimAlias = true;
|
||||||
|
# vimdiffAlias = true;
|
||||||
|
#
|
||||||
|
# extraLuaConfig = ''
|
||||||
|
# ${builtins.readFile ./init.lua}
|
||||||
|
# '';
|
||||||
|
# };
|
||||||
|
programs.nixvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
defaultEditor = true;
|
defaultEditor = true;
|
||||||
|
|
||||||
viAlias = true;
|
viAlias = true;
|
||||||
vimAlias = true;
|
vimAlias = true;
|
||||||
vimdiffAlias = true;
|
|
||||||
|
|
||||||
extraLuaConfig = ''
|
colorschemes.tokyonight = {
|
||||||
${builtins.readFile ./init.lua}
|
enable = true;
|
||||||
'';
|
style = "night";
|
||||||
|
};
|
||||||
|
|
||||||
|
globals = {
|
||||||
|
mapleader = " ";
|
||||||
|
maplocalleader = " ";
|
||||||
|
};
|
||||||
|
|
||||||
|
options = {
|
||||||
|
hlsearch = true;
|
||||||
|
number = true;
|
||||||
|
relativenumber = true;
|
||||||
|
mouse = "a";
|
||||||
|
showmode = false;
|
||||||
|
breakindent = true;
|
||||||
|
undofile = true;
|
||||||
|
ignorecase = true;
|
||||||
|
smartcase = true;
|
||||||
|
signcolumn = "yes";
|
||||||
|
updatetime = 250;
|
||||||
|
timeoutlen = 300;
|
||||||
|
splitright = true;
|
||||||
|
splitbelow = true;
|
||||||
|
|
||||||
|
list = true;
|
||||||
|
listchars = { tab = "» "; trail = "·"; nbsp = "␣"; };
|
||||||
|
|
||||||
|
inccommand = "split";
|
||||||
|
cursorline = true;
|
||||||
|
|
||||||
|
scrolloff = 10;
|
||||||
|
foldmethod = "expr";
|
||||||
|
foldexpr = "nvim_treesitter#foldexpr()";
|
||||||
|
|
||||||
|
autoGroups = {
|
||||||
|
"kickstart-highlight-yank" = { clear = true; };
|
||||||
|
"kickstart-lsp-attach" = {clear = true; };
|
||||||
|
};
|
||||||
|
|
||||||
|
autoCmd = [
|
||||||
|
{
|
||||||
|
event = "TextYankPost";
|
||||||
|
group = "kickstart-highlight-yank";
|
||||||
|
callback = ''function() vim.highlight.on_yank() end'';
|
||||||
|
}
|
||||||
|
{
|
||||||
|
event = "LspAttach";
|
||||||
|
group = "kickstart-lsp-attach";
|
||||||
|
callback = builtins.readFile ./lsp_autocmd.lua;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
keymaps = [
|
||||||
|
{ mode = "n"; key = "<Esc>"; action = "<cmd>nohlsearch<CR>";}
|
||||||
|
{ mode = "n"; key = "[d"; lua = true; action = "vim.diagnostic.goto_prev"; options.desc = "Go to previous [D]iagnostic message" ;}
|
||||||
|
{ mode = "n"; key = "]d"; lua = true; action = "vim.diagnostic.goto_next"; options.desc = "Go to next [D]iagnostic message" ;}
|
||||||
|
{ mode = "n"; key = "<leader>e"; lua = true; action = "vim.diagnostic.open_float"; options.desc = "Show diagnostic [E]rror messages" ;}
|
||||||
|
{ mode = "n"; key = "<leader>q"; lua = true; action = "vim.diagnostic.setloclist"; options.desc = "Open diagnostic [Q]uickfix list" ;}
|
||||||
|
{ mode = "t"; key = "<Esc><Esc>"; action = "<C-\\><C-n>"; options.desc = "Exit terminal mode" ;}
|
||||||
|
{ mode = "n"; key = "<C-h>"; action = "<C-w><C-h>"; options.desc = "Move focus to the left window" ;}
|
||||||
|
{ mode = "n"; key = "<C-l>"; action = "<C-w><C-l>"; options.desc = "Move focus to the right window" ;}
|
||||||
|
{ mode = "n"; key = "<C-j>"; action = "<C-w><C-j>"; options.desc = "Move focus to the lower window" ;}
|
||||||
|
{ mode = "n"; key = "<C-k>"; action = "<C-w><C-k>"; options.desc = "Move focus to the upper window" ;}
|
||||||
|
{ mode = "n"; key = "<leader>pv"; lua = true; action = "vim.cmd.Ex";}
|
||||||
|
{ mode = "x"; key = "<leader>p"; action = ''[["_dP]]'';}
|
||||||
|
{ mode = [ "n" "v" ]; key = "<leader>y"; action = ''[["+y]]'';}
|
||||||
|
{ mode = "n"; key = "<leader>Y"; action = ''[["+Y]]'';}
|
||||||
|
{ mode = [ "n" "v" ]; key = "<leader>d"; action = ''[["_d]]'';}
|
||||||
|
{ mode = "v"; key = "J"; action = ":m '>+1<CR>gv=gv";}
|
||||||
|
{ mode = "v"; key = "K"; action = ":m '<-2<CR>gv=gv";}
|
||||||
|
];
|
||||||
|
|
||||||
|
plugins = {
|
||||||
|
fugitive.enable = true;
|
||||||
|
nvim-colorizer.enable = true;
|
||||||
|
comment-nvim.enable = true;
|
||||||
|
gitsigns = {
|
||||||
|
enable = true;
|
||||||
|
signs = {
|
||||||
|
add.text = "+";
|
||||||
|
change.text = "~";
|
||||||
|
delete.text = "_";
|
||||||
|
topdelete.text = "‾";
|
||||||
|
changedelete.text = "~";
|
||||||
|
untracked.text = "┆";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
which-key = {
|
||||||
|
enable = true;
|
||||||
|
registrations = {
|
||||||
|
"<leader>c" = "[C]ode";
|
||||||
|
"<leader>d" = "[D]ocument";
|
||||||
|
"<leader>r" = "[R]ename";
|
||||||
|
"<leader>s" = "[S]earch";
|
||||||
|
"<leader>w" = "[W]orkspace";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
telescope = {
|
||||||
|
enable = true;
|
||||||
|
extensions = {
|
||||||
|
fzf-native.enable = true;
|
||||||
|
ui-select.enable = true;
|
||||||
|
};
|
||||||
|
keymaps = {
|
||||||
|
"<leader>sh" = {
|
||||||
|
action = "help_tags";
|
||||||
|
desc = "[S]earch [H]elp";
|
||||||
|
};
|
||||||
|
"<leader>sk" = { action = "keymaps"; desc = "[S]earch [K]eymaps"; };
|
||||||
|
"<leader>sf" = { action = "find_files"; desc = "[S]earch [F]iles"; };
|
||||||
|
"<leader>ss" = { action = "builtin"; desc = "[S]earch [S]elect Telescope"; };
|
||||||
|
"<leader>sw" = { action = "grep_string"; desc = "[S]earch current [W]ord"; };
|
||||||
|
"<leader>sg" = { action = "live_grep"; desc = "[S]earch by [G]rep"; };
|
||||||
|
"<leader>sd" = { action = "diagnostics"; desc = "[S]earch [D]iagnostics"; };
|
||||||
|
"<leader>sr" = { action = "resume"; desc = "[S]earch [R]esume"; };
|
||||||
|
"<leader>s." = { action = "oldfiles"; desc = ''[S]earch Recent Files ("." for repeat)''; };
|
||||||
|
"<leader><leader>" = { action = "buffers"; desc = "[ ] Find existing buffers"; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
conform-nvim = {
|
||||||
|
enable = true;
|
||||||
|
formatOnSave = {
|
||||||
|
timeoutMs = 500;
|
||||||
|
lspFallback = true;
|
||||||
|
};
|
||||||
|
formattersByFt = {
|
||||||
|
lua = [ "stylua" ];
|
||||||
|
python = [ "black" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
cmp = {
|
||||||
|
enable = true;
|
||||||
|
# TODO: find out how cmp works
|
||||||
|
};
|
||||||
|
todo-comments = {
|
||||||
|
enable = true;
|
||||||
|
signs = false;
|
||||||
|
};
|
||||||
|
mini = {
|
||||||
|
enable = true;
|
||||||
|
modules = {
|
||||||
|
ai = {
|
||||||
|
n_lines = 500;
|
||||||
|
};
|
||||||
|
surround = {};
|
||||||
|
statusline = {};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
treesitter = {
|
||||||
|
enable = true;
|
||||||
|
indent = true;
|
||||||
|
folding = true;
|
||||||
|
nixvimInjections = true;
|
||||||
|
};
|
||||||
|
treesitter-context = {
|
||||||
|
enable = true;
|
||||||
|
maxLines = 8;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
extraPlugins = with pkgs.vimPlugins; [
|
||||||
|
vim-sleuth
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
flake.lock
generated
12
flake.lock
generated
|
|
@ -194,11 +194,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710527391,
|
"lastModified": 1710532761,
|
||||||
"narHash": "sha256-3uM8+g/nb7ROgzSmJwOrKefctZpjR5uBJtUz4lpwWJI=",
|
"narHash": "sha256-SUXGZNrXX05YA9G6EmgupxhOr3swI1gcxLUeDMUhrEY=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "c781b28add41b74423ab2e64496d4fc91192e13a",
|
"rev": "206f457fffdb9a73596a4cb2211a471bd305243d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -265,11 +265,11 @@
|
||||||
"xdph": "xdph"
|
"xdph": "xdph"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710528257,
|
"lastModified": 1710547119,
|
||||||
"narHash": "sha256-DpKAky4UH1hovUq35MxIHikBKVxIw6KXrXkyFjn8I74=",
|
"narHash": "sha256-xLxbGRsKs40j+4tKeHydW1VUpCPOizYcduYQvBUitoY=",
|
||||||
"owner": "hyprwm",
|
"owner": "hyprwm",
|
||||||
"repo": "Hyprland",
|
"repo": "Hyprland",
|
||||||
"rev": "72d78eff95948a3eb3260791cfdf625c0102d33a",
|
"rev": "19c90048d65a5660384d2fb865926a366696d6be",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,6 @@
|
||||||
sddm
|
sddm
|
||||||
git
|
git
|
||||||
zsh
|
zsh
|
||||||
neovim
|
|
||||||
];
|
];
|
||||||
|
|
||||||
# TODO find list of fonts to install
|
# TODO find list of fonts to install
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,6 @@
|
||||||
sddm
|
sddm
|
||||||
git
|
git
|
||||||
zsh
|
zsh
|
||||||
neovim
|
|
||||||
];
|
];
|
||||||
|
|
||||||
# Some programs need SUID wrappers, can be configured further or are
|
# Some programs need SUID wrappers, can be configured further or are
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue