summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--configs/.vimrc21
-rw-r--r--configs/.ycm_extra_conf.py18
-rw-r--r--configs/plugins.vimrc16
-rw-r--r--modules/common.nix7
-rw-r--r--modules/vim.nix59
-rw-r--r--pkgs/default.nix2
-rw-r--r--pkgs/youcompleteme.nix32
7 files changed, 146 insertions, 9 deletions
diff --git a/configs/.vimrc b/configs/.vimrc
index 79ae89a..18fa910 100644
--- a/configs/.vimrc
+++ b/configs/.vimrc
@@ -1,3 +1,5 @@
+" COMMON VIM SETTINGS, REV. 2
+
 " NECESSITIES:
 
 " disable vi compatability, if still on for some reason
@@ -22,9 +24,6 @@ set nowrap
 " allow backspace over everything, default is dumb
 set backspace=indent,eol,start
 
-" never hide statusbar
-set laststatus=2
-
 " search settings
 set incsearch
 set hlsearch
@@ -36,12 +35,25 @@ nnoremap <silent> <C-L> :noh<C-R><CR><CR><C-L>
 " open windows below and to the right of current (why is the default opposite lol)
 set splitbelow splitright
 
+" bar settings
+" never hide statusbar
+set laststatus=2
 " show unfinished command in the last line (like 4dd)
 set showcmd
+" enable command tab completion
+set wildmenu
+" expand command line history
+set history=250
 
 " show relative numbers and absolute number for current line
 set number relativenumber
 
+" always show at least 2 more lines below or above cursor
+set scrolloff=2
+
+" don't ask for confirm to update file with outside changes
+set autoread
+
 " COLOR:
 
 " temporary default color scheme
@@ -50,6 +62,9 @@ colorscheme habamax
 " dont change default background color
 highlight Normal ctermbg=NONE
 
+" enable bright colors
+set t_Co=16
+
 " CUSTOMIZATION:
 
 " disable arrow keys, use hjkl instead
diff --git a/configs/.ycm_extra_conf.py b/configs/.ycm_extra_conf.py
new file mode 100644
index 0000000..abaa723
--- /dev/null
+++ b/configs/.ycm_extra_conf.py
@@ -0,0 +1,18 @@
+def Settings(**kwargs):
+    return {"ls": language_server_settings(kwargs["language"])}
+
+
+def language_server_settings(language):
+    match language:
+        case "nix":
+            return nil_settings()
+        case _:
+            return {}
+
+
+def nil_settings():
+    return {
+        "formatting": {
+            "command": ["nixfmt"],
+        },
+    }
diff --git a/configs/plugins.vimrc b/configs/plugins.vimrc
new file mode 100644
index 0000000..92d499d
--- /dev/null
+++ b/configs/plugins.vimrc
@@ -0,0 +1,16 @@
+" VIM PLUGIN SETTINGS
+
+" YOUCOMPLETEME:
+
+let g:ycm_extra_conf_globlist = ['/nix/store/*']
+let g:ycm_global_ycm_extra_conf = '@ycm_extra_conf@'
+
+let g:ycm_language_server =
+  \ [
+  \   {
+  \     'name': 'nix',
+  \     'cmdline': [ '/run/current-system/sw/bin/nil', '--stdio' ],
+  \     'filetypes': [ 'nix' ]
+  \   }
+  \ ]
+
diff --git a/modules/common.nix b/modules/common.nix
index e7e101b..937c7ef 100644
--- a/modules/common.nix
+++ b/modules/common.nix
@@ -6,6 +6,7 @@
     ./user.nix
     ./locale.nix
     ./nix-ld.nix
+    ./vim.nix
   ];
 
   boot.kernelPackages = pkgs.linuxPackages_latest;
@@ -62,12 +63,6 @@
   };
  
   programs = {
-    vim = {
-      defaultEditor = true;
-      package = pkgs.vim_configurable.customize {
-        vimrcFile = ../configs/.vimrc;
-      };
-    };
     fish.enable = true;
     git.enable = true;
     tmux.enable = true;
diff --git a/modules/vim.nix b/modules/vim.nix
new file mode 100644
index 0000000..dbe052b
--- /dev/null
+++ b/modules/vim.nix
@@ -0,0 +1,59 @@
+{
+  lib,
+  pkgs,
+  auxiliaryPkgs,
+  ...
+}:
+
+let
+  configs = [
+    ../configs/.vimrc
+    ../configs/plugins.vimrc
+  ];
+
+  configVars = {
+    "@ycm_extra_conf@" = ../configs/.ycm_extra_conf.py;
+  };
+
+  processRCFile =
+    f:
+    with builtins;
+    (replaceStrings
+      (lib.attrNames configVars)
+      (map toString (lib.attrValues configVars))
+      (readFile f));
+
+  customRC = builtins.foldl' (r: f: r + (processRCFile f)) "" configs;
+
+  vim-configured =
+    with pkgs;
+    vim-full.customize {
+      name = "vim"; # explicitly replace vim
+
+      vimrcConfig = {
+        inherit customRC;
+
+        packages.collection = with vimPlugins; {
+          start = [
+            fzf-vim
+            vim-fugitive
+            vim-gitgutter
+            vim-easymotion
+            vim-sleuth
+            vim-better-whitespace
+            vim-tmux-navigator
+          ] ++ (with auxiliaryPkgs; [ youcompleteme ]);
+
+          opt = [ ];
+        };
+      };
+    };
+
+in
+{
+  programs.vim = {
+    defaultEditor = true;
+
+    package = vim-configured;
+  };
+}
diff --git a/pkgs/default.nix b/pkgs/default.nix
index 5df7bc8..07ca87c 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -2,4 +2,6 @@
 
 {
   common = with pkgs; lib.recurseIntoAttrs (callPackage ./common.nix { });
+
+  youcompleteme = pkgs.callPackage ./youcompleteme.nix { };
 }
diff --git a/pkgs/youcompleteme.nix b/pkgs/youcompleteme.nix
new file mode 100644
index 0000000..190e4b5
--- /dev/null
+++ b/pkgs/youcompleteme.nix
@@ -0,0 +1,32 @@
+{
+  ycmd,
+  vimPlugins,
+  gopls,
+  ...
+}:
+
+let
+  ycmd-go = ycmd.overrideAttrs (
+    final: prev: {
+      pname = prev.pname + "-go";
+
+      installPhase =
+        prev.installPhase
+        + ''
+          TARGET=$out/lib/ycmd/third_party/go/bin
+          mkdir -p $TARGET
+          ln -sf ${gopls}/bin/gopls $TARGET
+        '';
+    }
+  );
+in
+vimPlugins.YouCompleteMe.overrideAttrs (
+  final: prev: {
+    buildPhase =
+      prev.buildPhase
+      + ''
+        rm third_party/ycmd
+        ln -s ${ycmd-go}/lib/ycmd third_party
+      '';
+  }
+)