summaryrefslogtreecommitdiff
path: root/common/home/programs/nixvim
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2024-09-28 15:17:50 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2024-09-28 15:17:50 +0200
commitac7f8ef19b645af5afe8f5f8044868a0cf25a620 (patch)
tree24096bb105e6a74622418a61a792388f665cf223 /common/home/programs/nixvim
parentfbe7799a38a2dfe139261bb3bdeca6fa96d05145 (diff)
nixvim: refactor
Diffstat (limited to 'common/home/programs/nixvim')
-rw-r--r--common/home/programs/nixvim/default.nix195
-rw-r--r--common/home/programs/nixvim/plugins/cmp.nix45
-rw-r--r--common/home/programs/nixvim/plugins/dashboard.nix68
-rw-r--r--common/home/programs/nixvim/plugins/default.nix27
-rw-r--r--common/home/programs/nixvim/plugins/friendly-snippets.nix4
-rw-r--r--common/home/programs/nixvim/plugins/lsp-format.nix4
-rw-r--r--common/home/programs/nixvim/plugins/lsp.nix39
-rw-r--r--common/home/programs/nixvim/plugins/lualine.nix4
-rw-r--r--common/home/programs/nixvim/plugins/luasnip.nix4
-rw-r--r--common/home/programs/nixvim/plugins/nvim-tree.nix7
-rw-r--r--common/home/programs/nixvim/plugins/telescope.nix4
-rw-r--r--common/home/programs/nixvim/plugins/treesitter.nix24
12 files changed, 231 insertions, 194 deletions
diff --git a/common/home/programs/nixvim/default.nix b/common/home/programs/nixvim/default.nix
index 80de5a1..f8ec8c6 100644
--- a/common/home/programs/nixvim/default.nix
+++ b/common/home/programs/nixvim/default.nix
@@ -54,200 +54,7 @@
colorscheme = "gruvbox-dark-pale";
};
- plugins = {
- web-devicons.enable = true;
-
- dashboard = {
- enable = true;
- settings = {
- change_to_vcs_root = true;
- config = {
- footer = [ "" ];
-
- header = [
- "███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗"
- "████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║"
- "██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║"
- "██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║"
- "██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║"
- "╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝"
- ];
-
- mru = {
- limit = 10;
- };
-
- project = {
- enable = true;
- };
-
- packages.enable = false;
-
- shortcut = [
- {
- action = {
- __raw = ''
- function(path)
- vim.cmd('Telescope find_files')
- end
- '';
- };
- desc = "Files";
- group = "Label";
- icon = " ";
- icon_hl = "@variable";
- key = "f";
- }
- {
- action = {
- __raw = ''
- function()
- vim.cmd('cd ~/global/system/config'); vim.cmd('Telescope find_files')
- end
- '';
- };
- icon = "󱄅 ";
- icon_hl = "@variable";
- desc = "System Config";
- group = "Number";
- key = "c";
- }
- ];
-
- hide = [
- "statusline"
- "tabline"
- "winbar"
- ];
- };
- theme = "hyper";
- };
- };
-
- nvim-tree = {
- enable = true;
- autoClose = true;
- disableNetrw = true;
- hijackCursor = true;
- };
-
- telescope = {
- enable = true;
- };
-
- lualine = {
- enable = true;
- };
-
- treesitter = {
- enable = true;
- settings = {
- auto_install = true;
- highlight = {
- additional_vim_regex_highlighting = true;
- enable = true;
- };
- incremental_selection = {
- enable = true;
- keymaps = {
- init_selection = false;
- node_decremental = "grm";
- node_incremental = "grn";
- scope_incremental = "grc";
- };
- };
- indent = {
- enable = true;
- };
- sync_install = false;
- };
- };
-
- luasnip = {
- enable = true;
- };
-
- friendly-snippets = {
- enable = true;
- };
-
- cmp = {
- enable = true;
- autoEnableSources = true;
- settings = {
- mapping = {
- "<C-b>" = "cmp.mapping.scroll_docs(-4)";
- "<C-f>" = "cmp.mapping.scroll_docs(4)";
- "<C-Space>" = "cmp.mapping.complete()";
- "<C-e>" = "cmp.mapping.abort()";
- "<CR>" = "cmp.mapping.confirm({ select = true })";
- "<Tab>" = ''
- cmp.mapping(function(fallback)
- if cmp.visible() then
- cmp.select_next_item()
- else
- fallback()
- end
- end, { "i", "s" })
- '';
- "<S-Tab>" = ''
- cmp.mapping(function(fallback)
- if cmp.visible() then
- cmp.select_prev_item()
- else
- fallback()
- end
- end, { "i", "s" })
- '';
- };
- snippet = {
- expand = "function(args) require('luasnip').lsp_expand(args.body) end";
- };
- sources = [
- { name = "nvim_lsp"; }
- { name = "luasnip"; }
- { name = "path"; }
- { name = "buffer"; }
- ];
- };
- };
-
- lsp = {
- enable = true;
- servers = {
- bashls = {
- enable = true;
- package = pkgs.unstable.bash-language-server;
- };
- clangd.enable = true;
- nixd = {
- enable = true;
- settings.formatting.command = [ "nixfmt" ];
- };
- rust-analyzer = {
- enable = true;
- installCargo = true;
- installRustc = true;
- };
- pyright.enable = true;
- ocamllsp.enable = true;
- };
- keymaps.lspBuf = {
- "gd" = "definition";
- "gD" = "references";
- "gt" = "type_definition";
- "gi" = "implementation";
- "K" = "hover";
- "rn" = "rename";
- "<space>ca" = "code_action";
- "<space>f" = "format";
- };
- };
-
- lsp-format = {
- enable = true;
- };
- };
+ plugins = import ./plugins/default.nix;
globals = {
mapleader = ",";
diff --git a/common/home/programs/nixvim/plugins/cmp.nix b/common/home/programs/nixvim/plugins/cmp.nix
new file mode 100644
index 0000000..27cca04
--- /dev/null
+++ b/common/home/programs/nixvim/plugins/cmp.nix
@@ -0,0 +1,45 @@
+{ ... }:
+{
+ enable = true;
+ autoEnableSources = true;
+ settings = {
+ mapping = {
+ "<C-b>" = "cmp.mapping.scroll_docs(-4)";
+ "<C-f>" = "cmp.mapping.scroll_docs(4)";
+ "<C-Space>" = "cmp.mapping.complete()";
+ "<C-e>" = "cmp.mapping.abort()";
+ "<CR>" = "cmp.mapping.confirm({ select = true })";
+ "<Tab>" = ''
+ cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_next_item()
+ else
+ fallback()
+ end
+ end, { "i", "s" })
+ '';
+ "<S-Tab>" = ''
+ cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_prev_item()
+ else
+ fallback()
+ end
+ end, { "i", "s" })
+ '';
+ };
+ snippet = {
+ expand = ''
+ function(args)
+ require('luasnip').lsp_expand(args.body)
+ end
+ '';
+ };
+ sources = [
+ { name = "nvim_lsp"; }
+ { name = "luasnip"; }
+ { name = "path"; }
+ { name = "buffer"; }
+ ];
+ };
+}
diff --git a/common/home/programs/nixvim/plugins/dashboard.nix b/common/home/programs/nixvim/plugins/dashboard.nix
new file mode 100644
index 0000000..77a9f3e
--- /dev/null
+++ b/common/home/programs/nixvim/plugins/dashboard.nix
@@ -0,0 +1,68 @@
+{ ... }:
+{
+ enable = true;
+ settings = {
+ change_to_vcs_root = true;
+ config = {
+ footer = [ "" ];
+
+ header = [
+ "███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗"
+ "████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║"
+ "██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║"
+ "██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║"
+ "██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║"
+ "╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝"
+ ];
+
+ mru = {
+ limit = 10;
+ };
+
+ project = {
+ enable = true;
+ };
+
+ packages.enable = false;
+
+ shortcut = [
+ {
+ action = {
+ __raw = ''
+ function(path)
+ vim.cmd('Telescope find_files')
+ end
+ '';
+ };
+ desc = "Files";
+ group = "Label";
+ icon = " ";
+ icon_hl = "@variable";
+ key = "f";
+ }
+ {
+ action = {
+ __raw = ''
+ function()
+ vim.cmd('cd ~/global/system/config'); vim.cmd('Telescope find_files')
+ end
+ '';
+ };
+ icon = "󱄅 ";
+ icon_hl = "@variable";
+ desc = "System Config";
+ group = "Number";
+ key = "c";
+ }
+ ];
+
+ hide = [
+ "statusline"
+ "tabline"
+ "winbar"
+ ];
+ };
+ theme = "hyper";
+ };
+ };
+
diff --git a/common/home/programs/nixvim/plugins/default.nix b/common/home/programs/nixvim/plugins/default.nix
new file mode 100644
index 0000000..6005c57
--- /dev/null
+++ b/common/home/programs/nixvim/plugins/default.nix
@@ -0,0 +1,27 @@
+{ pkgs, ... }:
+let
+ plugins = [
+ "web-devicons"
+ "dashboard"
+ "nvim-tree"
+ "telescope"
+ "lualine"
+ "treesitter"
+ "luasnip"
+ "friendly-snippets"
+ "cmp"
+ "lsp"
+ ];
+in
+{
+ plugins = builtins.listToAttrs (
+ map (n: {
+ name = n;
+ value =
+ if builtins.pathExists ./${n}.nix then
+ (import ./${n}.nix { inherit pkgs; })
+ else
+ { enable = true; };
+ }) plugins
+ );
+}
diff --git a/common/home/programs/nixvim/plugins/friendly-snippets.nix b/common/home/programs/nixvim/plugins/friendly-snippets.nix
new file mode 100644
index 0000000..3887830
--- /dev/null
+++ b/common/home/programs/nixvim/plugins/friendly-snippets.nix
@@ -0,0 +1,4 @@
+{ ... }:
+{
+ enable = true;
+}
diff --git a/common/home/programs/nixvim/plugins/lsp-format.nix b/common/home/programs/nixvim/plugins/lsp-format.nix
new file mode 100644
index 0000000..3887830
--- /dev/null
+++ b/common/home/programs/nixvim/plugins/lsp-format.nix
@@ -0,0 +1,4 @@
+{ ... }:
+{
+ enable = true;
+}
diff --git a/common/home/programs/nixvim/plugins/lsp.nix b/common/home/programs/nixvim/plugins/lsp.nix
new file mode 100644
index 0000000..578518f
--- /dev/null
+++ b/common/home/programs/nixvim/plugins/lsp.nix
@@ -0,0 +1,39 @@
+{ pkgs, ... }:
+{
+ enable = true;
+ servers = {
+
+ bashls = {
+ enable = true;
+ package = pkgs.unstable.bash-language-server;
+ };
+
+ clangd.enable = true;
+
+ nixd = {
+ enable = true;
+ settings.formatting.command = [ "nixfmt" ];
+ };
+
+ rust-analyzer = {
+ enable = true;
+ installCargo = true;
+ installRustc = true;
+ };
+
+ pyright.enable = true;
+
+ ocamllsp.enable = true;
+ };
+
+ keymaps.lspBuf = {
+ "gd" = "definition";
+ "gD" = "references";
+ "gt" = "type_definition";
+ "gi" = "implementation";
+ "K" = "hover";
+ "rn" = "rename";
+ "<space>ca" = "code_action";
+ "<space>f" = "format";
+ };
+}
diff --git a/common/home/programs/nixvim/plugins/lualine.nix b/common/home/programs/nixvim/plugins/lualine.nix
new file mode 100644
index 0000000..3887830
--- /dev/null
+++ b/common/home/programs/nixvim/plugins/lualine.nix
@@ -0,0 +1,4 @@
+{ ... }:
+{
+ enable = true;
+}
diff --git a/common/home/programs/nixvim/plugins/luasnip.nix b/common/home/programs/nixvim/plugins/luasnip.nix
new file mode 100644
index 0000000..3887830
--- /dev/null
+++ b/common/home/programs/nixvim/plugins/luasnip.nix
@@ -0,0 +1,4 @@
+{ ... }:
+{
+ enable = true;
+}
diff --git a/common/home/programs/nixvim/plugins/nvim-tree.nix b/common/home/programs/nixvim/plugins/nvim-tree.nix
new file mode 100644
index 0000000..dbd3256
--- /dev/null
+++ b/common/home/programs/nixvim/plugins/nvim-tree.nix
@@ -0,0 +1,7 @@
+{ ... }:
+{
+ enable = true;
+ autoClose = true;
+ disableNetrw = true;
+ hijackCursor = true;
+}
diff --git a/common/home/programs/nixvim/plugins/telescope.nix b/common/home/programs/nixvim/plugins/telescope.nix
new file mode 100644
index 0000000..3887830
--- /dev/null
+++ b/common/home/programs/nixvim/plugins/telescope.nix
@@ -0,0 +1,4 @@
+{ ... }:
+{
+ enable = true;
+}
diff --git a/common/home/programs/nixvim/plugins/treesitter.nix b/common/home/programs/nixvim/plugins/treesitter.nix
new file mode 100644
index 0000000..3fbd4b6
--- /dev/null
+++ b/common/home/programs/nixvim/plugins/treesitter.nix
@@ -0,0 +1,24 @@
+{ ... }:
+{
+ enable = true;
+ settings = {
+ auto_install = true;
+ highlight = {
+ additional_vim_regex_highlighting = true;
+ enable = true;
+ };
+ incremental_selection = {
+ enable = true;
+ keymaps = {
+ init_selection = false;
+ node_decremental = "grm";
+ node_incremental = "grn";
+ scope_incremental = "grc";
+ };
+ };
+ indent = {
+ enable = true;
+ };
+ sync_install = false;
+ };
+}