add refactoring

This commit is contained in:
Kopatz
2024-05-16 22:40:39 +02:00
parent 38bfbe82c6
commit 08683d98e7
6 changed files with 88 additions and 23 deletions

View File

@@ -28,6 +28,7 @@
end
'';
sources = [
{ name = "path"; groupIndex = 1; }
{ name = "nvim_lsp"; }
{ name = "luasnip"; }
{
@@ -35,7 +36,6 @@
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
}
{ name = "nvim_lua"; }
{ name = "path"; }
{ name = "copilot"; }
];

View File

@@ -93,11 +93,6 @@
}
# Tabs
{
mode = "n";
key = "<leader>t";
action = "+tab";
}
{
mode = "n";
key = "<leader>tn";
@@ -133,11 +128,6 @@
}
# Trouble
{
mode = "n";
key = "<leader>d";
action = "+diagnostics/debug";
}
{
key = "<leader>dt";
action = "<CMD>TroubleToggle<CR>";
@@ -145,11 +135,6 @@
}
# Rust
{
mode = "n";
key = "<leader>r";
action = "+rust";
}
{
# Start standalone rust-analyzer (fixes issues when opening files from nvim tree)
mode = "n";
@@ -157,5 +142,37 @@
action = "<CMD>RustStartStandaloneServerForBuffer<CR>";
options.desc = "Start standalone rust-analyzer";
}
# refactoring
{
mode = "n";
key = "<leader>re";
action = ":Refactor extract_var ";
options.desc = "Extract to variable";
}
{
mode = "n";
key = "<leader>rE";
action = ":Refactor extract ";
options.desc = "Extract to function";
}
{
mode = "n";
key = "<leader>rb";
action = ":Refactor extract_block ";
options.desc = "Extract to block";
}
{
mode = "n";
key = "<leader>ri";
action = ":Refactor inline_var ";
options.desc = "Inline variable";
}
{
mode = "n";
key = "<leader>rI";
action = ":Refactor inline_func ";
options.desc = "Inline function";
}
];
}

View File

@@ -1,4 +1,5 @@
{ lib, pkgs, ... }:
# https://nix-community.github.io/nixvim/NeovimOptions/index.html
let
args = { inherit lib pkgs; };
@@ -12,6 +13,7 @@ let
./bufferline.nix
./cmp.nix
./fidget.nix
./refactoring.nix
./git.nix
./lightline.nix
./lsp.nix

View File

@@ -9,11 +9,50 @@
nixd.enable = true;
};
keymaps.lspBuf = {
"gd" = "definition";
"gD" = "references";
"gt" = "type_definition";
"gi" = "implementation";
"K" = "hover";
gd = {
action = "definition";
desc = "LSP: [G]o to [D]efinition";
};
gD = {
action = "declaration";
desc = "LSP: [G]o to [D]eclaration";
};
gT = {
action = "type_definition";
desc = "Goto type definition";
};
gr = {
action = "references";
desc = "LSP: [G]o to [R]eferences";
};
gI = {
action = "implementation";
desc = "LSP: [G]o to [I]mplementation";
};
"K" = {
action = "hover";
desc = "LSP: Show documentation";
};
"<c-k>" = {
action = "signature_help";
desc = "LSP: Show signature help";
};
"<leader>rn" = {
action = "rename";
desc = "LSP: [R]e[n]ame";
};
"<leader>ca" = {
action = "code_action";
desc = "LSP: [C]ode [A]ction";
};
"<leader>ds" = {
action = "document_symbol";
desc = "LSP: [D]ocument [S]ymbols";
};
"<leader>ws" = {
action = "workspace_symbol";
desc = "LSP [W]orkspace [S]ymbols";
};
};
};
lsp-lines = {

View File

@@ -0,0 +1,3 @@
{
plugins = { refactoring.enable = true; };
}

View File

@@ -5,11 +5,15 @@
"<leader>sg" = "live_grep";
"<leader>sf" = {
action = "find_files";
options = { desc = "[S]earch [F]iles"; };
options.desc = "[S]earch [F]iles";
};
"<leader>gf" = {
action = "git_files";
options = { desc = "Search [G]it [F]iles"; };
options.desc = "Search [G]it [F]iles";
};
"<leader><space>" = {
action = "buffers";
options.desc = "List buffers";
};
};
extensions.fzf-native = { enable = true; };