aboutsummaryrefslogtreecommitdiffstats
path: root/modules/tools/editor
diff options
context:
space:
mode:
authorArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2024-09-24 23:13:51 +0530
committerArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2024-09-24 23:13:51 +0530
commitc0c5087218c27e31c3e6f66f3937bff22fa0f647 (patch)
treedede2292db1423cef901932a7898ec951c9d2345 /modules/tools/editor
parent21265ba643f1c12ad40e5195de8a3a97682adbde (diff)
downloadhome-manager-config-c0c5087218c27e31c3e6f66f3937bff22fa0f647.tar.gz
home-manager-config-c0c5087218c27e31c3e6f66f3937bff22fa0f647.zip
Using nix flake modules to manage the configurations.
Diffstat (limited to 'modules/tools/editor')
-rw-r--r--modules/tools/editor/default.nix7
-rw-r--r--modules/tools/editor/neovim/default.nix43
-rw-r--r--modules/tools/editor/neovim/keybindings.lua8
-rw-r--r--modules/tools/editor/neovim/options.lua21
-rw-r--r--modules/tools/editor/neovim/plugins/base16.lua6
-rw-r--r--modules/tools/editor/neovim/plugins/comment.lua1
-rw-r--r--modules/tools/editor/neovim/plugins/lualine.lua5
-rw-r--r--modules/tools/editor/neovim/plugins/nvim-tree.lua13
-rw-r--r--modules/tools/editor/neovim/plugins/treesitter.nix13
9 files changed, 117 insertions, 0 deletions
diff --git a/modules/tools/editor/default.nix b/modules/tools/editor/default.nix
new file mode 100644
index 0000000..1a146bf
--- /dev/null
+++ b/modules/tools/editor/default.nix
@@ -0,0 +1,7 @@
+{ lib, config, ... }:
+
+{
+ imports = [
+ ./neovim
+ ];
+}
diff --git a/modules/tools/editor/neovim/default.nix b/modules/tools/editor/neovim/default.nix
new file mode 100644
index 0000000..e06ec88
--- /dev/null
+++ b/modules/tools/editor/neovim/default.nix
@@ -0,0 +1,43 @@
+{ pkgs, config, lib, ... }:
+
+{
+ options = {
+ neovim.enable = lib.mkEnableOption "Enables neovim.";
+ };
+
+ config = lib.mkIf config.neovim.enable {
+ programs.neovim.enable = true;
+ programs.neovim.viAlias = true;
+ programs.neovim.vimAlias = true;
+ programs.neovim.vimdiffAlias = true;
+ programs.neovim.defaultEditor = true;
+
+ programs.neovim.extraPackages = with pkgs; [
+ gcc # Required for treesitter
+ ];
+
+ programs.neovim.extraLuaConfig =
+ ''
+ ${builtins.readFile ./options.lua}
+ ${builtins.readFile ./keybindings.lua}
+
+ -- Plugins configuration
+ ${builtins.readFile ./plugins/comment.lua}
+ ${builtins.readFile ./plugins/lualine.lua}
+ ${import ./plugins/treesitter.nix config}
+ ${builtins.readFile ./plugins/base16.lua}
+ ${builtins.readFile ./plugins/nvim-tree.lua}
+ '';
+
+ programs.neovim.plugins = with pkgs.vimPlugins; [
+ comment-nvim
+ lualine-nvim
+ nvim-treesitter
+ nvim-web-devicons
+ nvim-tree-lua
+ (base16-vim.overrideAttrs (old: {
+ patchPhase = "ln -s ${config.scheme base16-vim} colors/base16-scheme.vim";
+ }))
+ ];
+ };
+}
diff --git a/modules/tools/editor/neovim/keybindings.lua b/modules/tools/editor/neovim/keybindings.lua
new file mode 100644
index 0000000..3e8e0fa
--- /dev/null
+++ b/modules/tools/editor/neovim/keybindings.lua
@@ -0,0 +1,8 @@
+-- Navigate splits
+vim.keymap.set("n", "<C-h>", ":wincmd h<CR>", { silent = true });
+vim.keymap.set("n", "<C-j>", ":wincmd j<CR>", { silent = true });
+vim.keymap.set("n", "<C-k>", ":wincmd k<CR>", { silent = true });
+vim.keymap.set("n", "<C-l>", ":wincmd l<CR>", { silent = true });
+
+-- NvimTree
+vim.keymap.set("n", "<C-n>", ":NvimTreeToggle<CR>", { silent = true });
diff --git a/modules/tools/editor/neovim/options.lua b/modules/tools/editor/neovim/options.lua
new file mode 100644
index 0000000..b1fe9cb
--- /dev/null
+++ b/modules/tools/editor/neovim/options.lua
@@ -0,0 +1,21 @@
+vim.g.mapleader = " ";
+vim.g.maplocalleader = " ";
+
+vim.o.clipboard = "unnamedplus";
+
+vim.o.number = true;
+vim.o.list = true;
+vim.o.listchars = "tab:| ,trail:_,lead:_";
+
+vim.o.laststatus = 3;
+
+vim.o.signcolumn = "auto";
+vim.opt.fillchars = { eob = " " };
+
+vim.o.tabstop = 2;
+vim.o.shiftwidth = 2;
+vim.o.expandtab = false;
+
+vim.o.updatetime = 300;
+
+vim.o.mouse = "a";
diff --git a/modules/tools/editor/neovim/plugins/base16.lua b/modules/tools/editor/neovim/plugins/base16.lua
new file mode 100644
index 0000000..9843b76
--- /dev/null
+++ b/modules/tools/editor/neovim/plugins/base16.lua
@@ -0,0 +1,6 @@
+vim.o.termguicolors = true;
+vim.opt.termguicolors = true;
+vim.o.background = "dark";
+vim.g.base16colorspace = 256
+vim.cmd.colorscheme("base16-scheme");
+vim.api.nvim_set_hl(0, "LineNr", { link = "Normal" }); -- disable the background of line numbers
diff --git a/modules/tools/editor/neovim/plugins/comment.lua b/modules/tools/editor/neovim/plugins/comment.lua
new file mode 100644
index 0000000..9086261
--- /dev/null
+++ b/modules/tools/editor/neovim/plugins/comment.lua
@@ -0,0 +1 @@
+require("Comment").setup();
diff --git a/modules/tools/editor/neovim/plugins/lualine.lua b/modules/tools/editor/neovim/plugins/lualine.lua
new file mode 100644
index 0000000..ba2eda6
--- /dev/null
+++ b/modules/tools/editor/neovim/plugins/lualine.lua
@@ -0,0 +1,5 @@
+require("lualine").setup {
+ options = {
+ globalstatus = true,
+ },
+};
diff --git a/modules/tools/editor/neovim/plugins/nvim-tree.lua b/modules/tools/editor/neovim/plugins/nvim-tree.lua
new file mode 100644
index 0000000..c6c4102
--- /dev/null
+++ b/modules/tools/editor/neovim/plugins/nvim-tree.lua
@@ -0,0 +1,13 @@
+require("nvim-tree").setup {
+ filters = {
+ enable = false
+ },
+ renderer = {
+ indent_markers = {
+ enable = true
+ },
+ root_folder_label = function(path)
+ return vim.fn.fnamemodify(path, ":t")
+ end,
+ },
+};
diff --git a/modules/tools/editor/neovim/plugins/treesitter.nix b/modules/tools/editor/neovim/plugins/treesitter.nix
new file mode 100644
index 0000000..05f1f2a
--- /dev/null
+++ b/modules/tools/editor/neovim/plugins/treesitter.nix
@@ -0,0 +1,13 @@
+config:
+
+''
+require("nvim-treesitter.configs").setup {
+ auto_install = true,
+ highlight = {
+ enable = true,
+ },
+ parser_install_dir = "${config.xdg.dataHome}/nvim",
+};
+
+vim.opt.runtimepath:append("${config.xdg.dataHome}/nvim");
+''