Skip to content

Commit

Permalink
Refactor nixvim config
Browse files Browse the repository at this point in the history
  • Loading branch information
arunoruto committed Jul 4, 2024
1 parent 7b31f14 commit 449186f
Show file tree
Hide file tree
Showing 26 changed files with 305 additions and 207 deletions.
5 changes: 3 additions & 2 deletions home-manager/server/shell/nvim/default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
{pkgs, ...}: {
imports = [
./auto.nix
# ./auto.nix
./options.nix
./keymaps.nix
./plugins
];

programs.nixvim = {
enable = true;
package = pkgs.unstable.neovim-unwrapped;
# vimAlias = true;
editorconfig.enable = true;
colorschemes.catppuccin = {
Expand Down
35 changes: 0 additions & 35 deletions home-manager/server/shell/nvim/default.nix.bak

This file was deleted.

3 changes: 2 additions & 1 deletion home-manager/server/shell/nvim/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
};
globals = {
mapleader = " ";
maplocalleader = ",";
maplocalleader = " ";
# maplocalleader = ",";
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
name = "luasnip";
keywordLength = 3;
}
{name = "copilot";}
# {name = "copilot";}
];
#settings = {
# completion.completeopt = "menu,menuone,preview,noselect";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
imports = [
#./autopairs.nix
./cmp.nix
#./copilot.nix
#./lspkind.nix
#./luasnip.nix
];
}
30 changes: 30 additions & 0 deletions home-manager/server/shell/nvim/plugins/coding/debug.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
programs.nixvim = {
plugins.dap = {
enable = true;
extensions.dap-ui = {
enable = true;
};
};
keymaps = [
{
mode = ["n"];
key = "<leader>db";
action = "<cmd>DapToggleBreakpoint<cr>";
options = {
silent = true;
desc = "Toggle Breakpoint";
};
}
{
mode = ["n"];
key = "<leader>dpr";
action.__raw = ''function() require("dap-python").test_method() end'';
options = {
silent = true;
desc = "Toggle Breakpoint";
};
}
];
};
}
11 changes: 11 additions & 0 deletions home-manager/server/shell/nvim/plugins/coding/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
imports = [
./languages

./completion

./debug.nix
./lsp.nix
./none-ls.nix
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
imports = [
./nix.nix
./python.nix
];
}
30 changes: 30 additions & 0 deletions home-manager/server/shell/nvim/plugins/coding/languages/nix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
config,
lib,
pkgs,
...
}: {
programs.nixvim = {
plugins = {
lsp = {
servers = {
nil-ls.enable = true;
nixd.enable = true;
};
};
none-ls = {
sources = {
code_actions = {
statix.enable = true;
};
diagnostics = {
statix.enable = true;
};
formatting = {
alejandra.enable = true;
};
};
};
};
};
}
38 changes: 38 additions & 0 deletions home-manager/server/shell/nvim/plugins/coding/languages/python.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
config,
lib,
pkgs,
...
}: {
programs.nixvim = {
plugins = {
lsp = {
servers = {
pyright.enable = true;
ruff.enable = true;
};
};
none-ls = {
sources = {
diagnostics = {
pylint.enable = true;
};
formatting = {
black = {
enable = true;
withArgs = ''
{
extra_args = { "--fast" },
}
'';
};
};
};
};
dap.extensions.dap-python = {
enable = true;
# package = pkgs.dap-python;
};
};
};
}
123 changes: 123 additions & 0 deletions home-manager/server/shell/nvim/plugins/coding/lsp.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
config,
lib,
pkgs,
...
}: {
programs.nixvim = {
plugins = {
lsp-format.enable = true;
lsp = {
enable = true;
keymaps = {
silent = true;
lspBuf = {
gd = {
action = "definition";
desc = "Goto Definition";
};
gr = {
action = "references";
desc = "Goto References";
};
gD = {
action = "declaration";
desc = "Goto Declaration";
};
gI = {
action = "implementation";
desc = "Goto Implementation";
};
gT = {
action = "type_definition";
desc = "Type Definition";
};
K = {
action = "hover";
desc = "Hover";
};
"<leader>cw" = {
action = "workspace_symbol";
desc = "Workspace Symbol";
};
"<leader>cr" = {
action = "rename";
desc = "Rename";
};
};
diagnostic = {
"<leader>dl" = {
action = "open_float";
desc = "Line Diagnostics";
};
"<leader>dn" = {
action = "goto_next";
desc = "Next Diagnostic";
};
"<leader>dp" = {
action = "goto_prev";
desc = "Previous Diagnostic";
};
};
};
};
};
extraConfigLua = ''
local cmp_lsp_capabilities = require("cmp_nvim_lsp").default_capabilities()
cmp_lsp_capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true
}
-- used to enable autocompletion (assign to every lsp server config)
local language_servers = require("lspconfig").util.available_servers()
for _, ls in ipairs(language_servers) do
require('lspconfig')[ls].setup({
capabilities = cmp_lsp_capabilities,
})
end
-- -- list all LSPs from above
-- local lsps = {${lib.concatMapStringsSep "," (x: ''"${x}"'') (lib.filter (server: config.programs.nixvim.plugins.lsp.servers."${server}".enable) (lib.attrNames config.programs.nixvim.plugins.lsp.servers))}}
-- for i, v in ipairs(lsps) do
-- lsps[i] = lsps[i]:gsub("-", "_")
-- -- if v == "ruff-lsp" then
-- -- lsps[i] = "ruff_lsp"
-- -- elseif v == "lua-ls" then
-- -- lsps[i] = "lua_ls"
-- -- end
-- end
-- -- combinatination what been done in:
-- -- joseans blog: https://www.josean.com/posts/how-to-setup-neovim-2024 (nvim-lspconfig section)
-- -- and in this config: https://github.com/pete3n/nixvim-flake/blob/main/config/lsp.nix
-- for _, lsp in pairs(lsps) do
-- require("lspconfig")[lsp].setup({
-- capabilities = capabilities,
-- })
-- end
local _border = "rounded"
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
vim.lsp.handlers.hover, {
border = _border
}
)
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
vim.lsp.handlers.signature_help, {
border = _border
}
)
vim.diagnostic.config{
float={border=_border}
};
require('lspconfig.ui.windows').default_options = {
border = _border
}
'';
};
}
20 changes: 20 additions & 0 deletions home-manager/server/shell/nvim/plugins/coding/none-ls.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
programs.nixvim = {
plugins.none-ls = {
enable = true;
enableLspFormat = true;
updateInInsert = false;
};
keymaps = [
{
mode = ["n" "v"];
key = "<leader>cf";
action = "<cmd>lua vim.lsp.buf.format()<cr>";
options = {
silent = true;
desc = "Format";
};
}
];
};
}
9 changes: 0 additions & 9 deletions home-manager/server/shell/nvim/plugins/completion/default.nix

This file was deleted.

11 changes: 0 additions & 11 deletions home-manager/server/shell/nvim/plugins/debug/default.nix

This file was deleted.

6 changes: 0 additions & 6 deletions home-manager/server/shell/nvim/plugins/debug/python.nix

This file was deleted.

5 changes: 0 additions & 5 deletions home-manager/server/shell/nvim/plugins/debug/ui.nix

This file was deleted.

Loading

0 comments on commit 449186f

Please sign in to comment.