From 001642dc947e292665cb3c978278d4bed3b5b470 Mon Sep 17 00:00:00 2001 From: Fabian Montero Date: Wed, 20 Nov 2024 17:04:00 -0600 Subject: [PATCH] modularize neovim and terminal --- home/default.nix | 5 ++ home/modules/default.nix | 11 +++++ home/modules/neovim.nix | 48 +++++++++++++++++++ home/modules/terminal/default.nix | 37 ++++++++++++++ .../apps => modules}/terminal/kitty.conf.nix | 0 .../fabian@posixlycorrect/apps/default.nix | 2 - .../fabian@posixlycorrect/apps/neovim.nix | 40 ---------------- .../apps/terminal/default.nix | 32 ------------- .../fabian@posixlycorrect/default.nix | 3 ++ 9 files changed, 104 insertions(+), 74 deletions(-) create mode 100644 home/modules/default.nix create mode 100644 home/modules/neovim.nix create mode 100644 home/modules/terminal/default.nix rename home/{platforms/fabian@posixlycorrect/apps => modules}/terminal/kitty.conf.nix (100%) delete mode 100644 home/platforms/fabian@posixlycorrect/apps/neovim.nix delete mode 100644 home/platforms/fabian@posixlycorrect/apps/terminal/default.nix diff --git a/home/default.nix b/home/default.nix index 4d1f088..0c7c6f3 100644 --- a/home/default.nix +++ b/home/default.nix @@ -7,6 +7,11 @@ ... }: with lib; { + + imports = [ + ./modules + ]; + xdg.enable = true; programs = { diff --git a/home/modules/default.nix b/home/modules/default.nix new file mode 100644 index 0000000..89e2418 --- /dev/null +++ b/home/modules/default.nix @@ -0,0 +1,11 @@ +{ + config, + lib, + pkgs, + ... +}: { + imports = [ + ./terminal + ./neovim.nix + ]; +} diff --git a/home/modules/neovim.nix b/home/modules/neovim.nix new file mode 100644 index 0000000..b026484 --- /dev/null +++ b/home/modules/neovim.nix @@ -0,0 +1,48 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; let + cfg = config.local.apps.neovim; +in { + options.local.apps.neovim = { + enable = mkEnableOption "Neovim settings"; + }; + config = mkIf cfg.enable { + programs.neovim = { + enable = true; + viAlias = true; + vimAlias = true; + defaultEditor = true; + + extraConfig = '' + set nobackup + set showmatch " show matching + set hlsearch " highlight search + set incsearch " incremental search + set tabstop=4 " number of columns occupied by a tab + set softtabstop=4 " see multiple spaces as tabstops so does the right thing + set shiftwidth=4 " width for autoindents + set autoindent " indent a new line the same amount as the line just typed + set number " add line numbers + set wildmode=longest,list " get bash-like tab completions + set cc=80 " set an 80 column border for good coding style + filetype plugin indent on " allow auto-indenting depending on file type + syntax on " syntax highlighting + set mouse=a " enable mouse click + set clipboard=unnamedplus " using system clipboard + filetype plugin on + set cursorline " highlight current cursorline + set ttyfast " Speed up scrolling in Vim + set noswapfile " disable creating swap file + ''; + + plugins = with pkgs.vimPlugins; [ + vim-nix + vim-multiple-cursors + ]; + }; + }; +} diff --git a/home/modules/terminal/default.nix b/home/modules/terminal/default.nix new file mode 100644 index 0000000..35df791 --- /dev/null +++ b/home/modules/terminal/default.nix @@ -0,0 +1,37 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; let + cfg = config.local.apps.terminal; +in { + options.local.apps.terminal.enable = mkEnableOption "Terminal emulator settings"; + config = mkIf cfg.enable { + programs = { + kitty = { + enable = true; + extraConfig = import ./kitty.conf.nix; + }; + + tmux = { + enable = true; + aggressiveResize = true; + clock24 = true; + escapeTime = 10; + terminal = "xterm-256color"; + keyMode = "emacs"; + + extraConfig = '' + set -g mouse on + set -ga update-environment " LIFT_PID" + set -g set-titles on + set -g renumber-windows on + set -sa terminal-overrides ',xterm-termite:RGB' + set -g status-right "#{?window_bigger,[#{window_offset_x}#,#{window_offset_y}] ,} %H:%M %d-%b-%y" + ''; + }; + }; + }; +} diff --git a/home/platforms/fabian@posixlycorrect/apps/terminal/kitty.conf.nix b/home/modules/terminal/kitty.conf.nix similarity index 100% rename from home/platforms/fabian@posixlycorrect/apps/terminal/kitty.conf.nix rename to home/modules/terminal/kitty.conf.nix diff --git a/home/platforms/fabian@posixlycorrect/apps/default.nix b/home/platforms/fabian@posixlycorrect/apps/default.nix index d3250c5..9b071f6 100644 --- a/home/platforms/fabian@posixlycorrect/apps/default.nix +++ b/home/platforms/fabian@posixlycorrect/apps/default.nix @@ -6,8 +6,6 @@ }: { imports = [ ./steam - ./terminal - ./neovim.nix ]; home.packages = with pkgs; [ diff --git a/home/platforms/fabian@posixlycorrect/apps/neovim.nix b/home/platforms/fabian@posixlycorrect/apps/neovim.nix deleted file mode 100644 index 7492348..0000000 --- a/home/platforms/fabian@posixlycorrect/apps/neovim.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: { - programs.neovim = { - enable = true; - viAlias = true; - vimAlias = true; - defaultEditor = true; - - extraConfig = '' - set nobackup - set showmatch " show matching - set hlsearch " highlight search - set incsearch " incremental search - set tabstop=4 " number of columns occupied by a tab - set softtabstop=4 " see multiple spaces as tabstops so does the right thing - set shiftwidth=4 " width for autoindents - set autoindent " indent a new line the same amount as the line just typed - set number " add line numbers - set wildmode=longest,list " get bash-like tab completions - set cc=80 " set an 80 column border for good coding style - filetype plugin indent on " allow auto-indenting depending on file type - syntax on " syntax highlighting - set mouse=a " enable mouse click - set clipboard=unnamedplus " using system clipboard - filetype plugin on - set cursorline " highlight current cursorline - set ttyfast " Speed up scrolling in Vim - set noswapfile " disable creating swap file - ''; - - plugins = with pkgs.vimPlugins; [ - vim-nix - vim-multiple-cursors - ]; - }; -} diff --git a/home/platforms/fabian@posixlycorrect/apps/terminal/default.nix b/home/platforms/fabian@posixlycorrect/apps/terminal/default.nix deleted file mode 100644 index 57a7cc4..0000000 --- a/home/platforms/fabian@posixlycorrect/apps/terminal/default.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -with lib; let - cfg = config.local.apps.terminal; -in { - kitty = { - enable = true; - extraConfig = import ./kitty.conf.nix; - }; - - tmux = { - enable = true; - aggressiveResize = true; - clock24 = true; - escapeTime = 10; - terminal = "xterm-256color"; - keyMode = "emacs"; - - extraConfig = '' - set -g mouse on - set -ga update-environment " LIFT_PID" - set -g set-titles on - set -g renumber-windows on - set -sa terminal-overrides ',xterm-termite:RGB' - set -g status-right "#{?window_bigger,[#{window_offset_x}#,#{window_offset_y}] ,} %H:%M %d-%b-%y" - ''; - }; -} diff --git a/home/platforms/fabian@posixlycorrect/default.nix b/home/platforms/fabian@posixlycorrect/default.nix index 41128d0..e37ad9f 100644 --- a/home/platforms/fabian@posixlycorrect/default.nix +++ b/home/platforms/fabian@posixlycorrect/default.nix @@ -12,6 +12,9 @@ ./isolation.nix ]; + local.apps.terminal.enable = true; + local.apps.neovim.enable = true; + nix.registry = { "system".to = { type = "path";