From d6dc868814566b294c482a1e83f46f6dac3459be Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 3 Jun 2024 11:05:46 +0100 Subject: [PATCH] modularise nixvim --- flake.lock | 77 +++- flake.nix | 2 + home/common/core/default.nix | 2 +- home/common/core/nixvim.nix | 383 ------------------ home/common/core/nixvim/default.nix | 43 ++ home/common/core/nixvim/keymaps.nix | 85 ++++ home/common/core/nixvim/options.nix | 35 ++ home/common/core/nixvim/plugins/colorizer.nix | 6 + home/common/core/nixvim/plugins/conform.nix | 21 + home/common/core/nixvim/plugins/default.nix | 30 ++ home/common/core/nixvim/plugins/gitsigns.nix | 35 ++ home/common/core/nixvim/plugins/harpoon.nix | 8 + home/common/core/nixvim/plugins/lsp.nix | 51 +++ home/common/core/nixvim/plugins/lspkind.nix | 13 + home/common/core/nixvim/plugins/lualine.nix | 22 + home/common/core/nixvim/plugins/nvim-tree.nix | 12 + home/common/core/nixvim/plugins/surround.nix | 3 + home/common/core/nixvim/plugins/telescope.nix | 6 + .../common/core/nixvim/plugins/treesitter.nix | 5 + home/common/core/nixvim/theme.nix | 15 + .../optional/desktop/common/default.nix | 2 +- .../optional/desktop/hyprland/default.nix | 4 +- .../optional/desktop/wayland/default.nix | 13 + .../optional/desktop/{ => wayland}/mako.nix | 0 .../swww-wallpaper-changer.nix} | 0 .../optional/desktop/{ => wayland}/waybar.nix | 0 pkgs/default.nix | 2 +- pkgs/sqlfmt.nix | 25 ++ 28 files changed, 506 insertions(+), 394 deletions(-) delete mode 100644 home/common/core/nixvim.nix create mode 100644 home/common/core/nixvim/default.nix create mode 100644 home/common/core/nixvim/keymaps.nix create mode 100644 home/common/core/nixvim/options.nix create mode 100644 home/common/core/nixvim/plugins/colorizer.nix create mode 100644 home/common/core/nixvim/plugins/conform.nix create mode 100644 home/common/core/nixvim/plugins/default.nix create mode 100644 home/common/core/nixvim/plugins/gitsigns.nix create mode 100644 home/common/core/nixvim/plugins/harpoon.nix create mode 100644 home/common/core/nixvim/plugins/lsp.nix create mode 100644 home/common/core/nixvim/plugins/lspkind.nix create mode 100644 home/common/core/nixvim/plugins/lualine.nix create mode 100644 home/common/core/nixvim/plugins/nvim-tree.nix create mode 100644 home/common/core/nixvim/plugins/surround.nix create mode 100644 home/common/core/nixvim/plugins/telescope.nix create mode 100644 home/common/core/nixvim/plugins/treesitter.nix create mode 100644 home/common/core/nixvim/theme.nix create mode 100644 home/common/optional/desktop/wayland/default.nix rename home/common/optional/desktop/{ => wayland}/mako.nix (100%) rename home/common/optional/desktop/{wallpaper-changer/swww-wallpaper-changer/default.nix => wayland/swww-wallpaper-changer.nix} (100%) rename home/common/optional/desktop/{ => wayland}/waybar.nix (100%) create mode 100644 pkgs/sqlfmt.nix diff --git a/flake.lock b/flake.lock index 4032baa..118224c 100644 --- a/flake.lock +++ b/flake.lock @@ -18,7 +18,7 @@ }, "devshell": { "inputs": { - "flake-utils": "flake-utils", + "flake-utils": "flake-utils_2", "nixpkgs": [ "nixvim", "nixpkgs" @@ -125,6 +125,21 @@ } }, "flake-utils": { + "locked": { + "lastModified": 1642700792, + "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { "inputs": { "systems": "systems" }, @@ -247,6 +262,26 @@ "type": "github" } }, + "mach-nix": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "pypi-deps-db": "pypi-deps-db" + }, + "locked": { + "lastModified": 1654084003, + "narHash": "sha256-j/XrVVistvM+Ua+0tNFvO5z83isL+LBgmBi9XppxuKA=", + "owner": "DavHau", + "repo": "mach-nix", + "rev": "7e14360bde07dcae32e5e24f366c83272f52923f", + "type": "github" + }, + "original": { + "id": "mach-nix", + "ref": "3.5.0", + "type": "indirect" + } + }, "nix-colors": { "inputs": { "base16-schemes": "base16-schemes", @@ -305,15 +340,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1717112898, - "narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=", + "lastModified": 1643805626, + "narHash": "sha256-AXLDVMG+UaAGsGSpOtQHPIKB+IZ0KSd9WS77aanGzgc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0", + "rev": "554d2d8aa25b6e583575459c297ec23750adb6cb", "type": "github" }, "original": { "id": "nixpkgs", + "ref": "nixos-unstable", "type": "indirect" } }, @@ -364,6 +400,20 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1717112898, + "narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, "nixvim": { "inputs": { "devshell": "devshell", @@ -392,14 +442,31 @@ "type": "github" } }, + "pypi-deps-db": { + "flake": false, + "locked": { + "lastModified": 1643877077, + "narHash": "sha256-jv8pIvRFTP919GybOxXE5TfOkrjTbdo9QiCO1TD3ZaY=", + "owner": "DavHau", + "repo": "pypi-deps-db", + "rev": "da53397f0b782b0b18deb72ef8e0fb5aa7c98aa3", + "type": "github" + }, + "original": { + "owner": "DavHau", + "repo": "pypi-deps-db", + "type": "github" + } + }, "root": { "inputs": { "disko": "disko", "home-manager": "home-manager", "impermanence": "impermanence", + "mach-nix": "mach-nix", "nix-colors": "nix-colors", "nix-secrets": "nix-secrets", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_2", "nixpkgs-unstable": "nixpkgs-unstable", "nixvim": "nixvim", "sops-nix": "sops-nix" diff --git a/flake.nix b/flake.nix index 69da67a..212e550 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,8 @@ # Nixpkgs nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + mach-nix.url = "mach-nix/3.5.0"; + # Home manager home-manager = { url = "github:nix-community/home-manager"; diff --git a/home/common/core/default.nix b/home/common/core/default.nix index b3dc7d5..8ac9325 100644 --- a/home/common/core/default.nix +++ b/home/common/core/default.nix @@ -3,7 +3,7 @@ imports = [ inputs.nix-colors.homeManagerModules.default ./zsh.nix - ./nixvim.nix + ./nixvim ./fonts.nix ] ; diff --git a/home/common/core/nixvim.nix b/home/common/core/nixvim.nix deleted file mode 100644 index 9e66742..0000000 --- a/home/common/core/nixvim.nix +++ /dev/null @@ -1,383 +0,0 @@ -{ inputs, pkgs, config, ... }: { - imports = [ - inputs.nixvim.homeManagerModules.nixvim - ]; - - programs.nixvim = { - enable = true; - enableMan = true; # install man pages for nixvim options - - clipboard.register = "unnamedplus"; # use system clipboard instead of internal registers - - colorschemes.kanagawa = { - enable = true; - settings = { - commentStyle = { - italic = true; - }; - dimInactive = true; - terminalColors = true; - theme = "wave"; - transparent = false; - undercurl = true; - }; - }; - - # Base16 colorscheme -# colorschemes.base16 = { -# enable = true; -# colorscheme = { -# base00 = "#${config.colorScheme.colors.base00}"; -# base01 = "#${config.colorScheme.colors.base01}"; -# base02 = "#${config.colorScheme.colors.base02}"; -# base03 = "#${config.colorScheme.colors.base03}"; -# base04 = "#${config.colorScheme.colors.base04}"; -# base05 = "#${config.colorScheme.colors.base05}"; -# base06 = "#${config.colorScheme.colors.base06}"; -# base07 = "#${config.colorScheme.colors.base07}"; -# base08 = "#${config.colorScheme.colors.base08}"; -# base09 = "#${config.colorScheme.colors.base09}"; -# base0A = "#${config.colorScheme.colors.base0A}"; -# base0B = "#${config.colorScheme.colors.base0B}"; -# base0C = "#${config.colorScheme.colors.base0C}"; -# base0D = "#${config.colorScheme.colors.base0D}"; -# base0E = "#${config.colorScheme.colors.base0E}"; -# base0F = "#${config.colorScheme.colors.base0F}"; -# }; -# }; - - opts = { - # - # ========= General Appearance ========= - # - background = ""; - number = true; # show line numbers - relativenumber = true; # show relative linenumbers - laststatus = 0; # Display status line always - history = 1000; # Store lots of :cmdline history - showcmd = true; # Show incomplete cmds down the bottom - showmode = true; # Show current mode down the bottom - autoread = true; # Reload files changed outside vim - lazyredraw = true; # Redraw only when needed - showmatch = true; # highlight matching braces - ruler = true; # show current line and column - visualbell = true; # No sounds - - listchars = "trail:·"; # Display tabs and trailing spaces visually - - # ========= Font ========= - guifont = "NotoSansMono:h9"; # fontname:fontsize - - # ========= Cursor ========= - guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20,n-v-i:blinkon0"; - - # ========= Redirect Temp Files ========= - # backup - backupdir = "$HOME/.local/state/vim/backup//,/tmp//,."; - writebackup = false; - # swap - directory = "$HOME/.local/vim/swap//,/tmp//,."; - - # ================ Indentation ====================== - autoindent = true; - cindent = true; # automatically indent braces - smartindent = true; - smarttab = true; - shiftwidth = 2; - softtabstop = 4; - tabstop = 2; - expandtab = true; - - # ================ Folds ============================ - foldmethod = "indent"; # fold based on indent - foldnestmax = 3; # deepest fold is 3 levels - foldenable = false; # don't fold by default - - # ================ Completion ======================= - wildmode = "list:longest"; - wildmenu = true; # enable ctrl-n and ctrl-p to scroll thru matches - - # stuff to ignore when tab completing - wildignore = "*.o,*.obj,*~,vim/backups,sass-cache,DS_Store,vendor/rails/**,vendor/cache/**,*.gem,log/**,tmp/**,*.png,*.jpg,*.gif"; - - # ================ Scrolling ======================== - scrolloff = 4; # Start scrolling when we're 4 lines away from margins - sidescrolloff = 15; - sidescroll = 1; - - # ================ Searching ======================== - incsearch = true; - hlsearch = true; - ignorecase = true; - smartcase = true; - - # ================ Movement ======================== - backspace = "indent,eol,start"; # allow backspace in insert mode - }; - - # - # ========= UI Plugins ========= - # - - plugins.nvim-colorizer = { - enable = true; - fileTypes = [ "*" ]; - }; - - plugins.treesitter = { - enable = true; - }; - - plugins.lualine = { - enable = true; - theme = "auto"; - componentSeparators = { - left = ""; - right = ""; - }; - sectionSeparators = { - left = ""; - right = ""; - }; - sections = { - lualine_a = [ "mode" ]; - lualine_b = [ "branch" "diff" "diagnostics" ]; - lualine_c = [ "filename" ]; - lualine_x = [ "encoding" "fileformat" "filetype" ]; - lualine_y = [ "progress" ]; - lualine_z = [ "locations" ]; - }; - }; - - # - # ========= File Search ========= - # - plugins.telescope = { - # https://github.com/nvim-telescope/telescope.nvim - enable = true; - extensions.fzy-native.enable = true; - }; - - # ========= File Nav =========== - # - plugins.harpoon = { - enable = true; - keymaps = { - toggleQuickMenu = "b"; - }; - }; - - plugins.nvim-tree = { - enable = true; - view.width = { - min = 30; - max = -1; - padding = 1; - }; - disableNetrw = true; - filters.dotfiles = true; - - }; - - # - # ========== Dev Tools ========= - # - plugins.surround.enable = true; # vim-surround - - plugins.gitsigns = { - enable = true; - settings.signs.add = { - hl = "GitSignsAdd"; - text = " ▎"; - numhl = "GitSignsAddNr"; - linehl = "GitSignsAddLn"; - }; - settings.signs.change = { - hl = "GitSignsChange"; - text = " ▎"; - numhl = "GitSignsChangeNr"; - linehl = "GitSignsChangeLn"; - }; - settings.signs.delete = { - hl = "GitSignsDelete"; - text = " ●"; - numhl = "GitSignsDeleteNr"; - linehl = "GitSignsDeleteLn"; - }; - settings.signs.topdelete = { - hl = "GitSignsDelete"; - text = " ●"; - numhl = "GitSignsDeleteNr"; - linehl = "GitSignsDeleteLn"; - }; - settings.signs.changedelete = { - hl = "GitSignsChange"; - text = " ▎"; - numhl = "GitSignsChangeNr"; - linehl = "GitSignsChangeLn"; - }; - }; - - # Load Plugins that aren't provided as modules by nixvim - extraPlugins = builtins.attrValues { - inherit (pkgs.vimPlugins) - ale - vim-numbertoggle# Use relative number on focused buffer only - vimade# Dim unfocused buffers - vimwiki# Vim Wiki - YouCompleteMe# Code completion engine - vim-dadbod - vim-dadbod-ui - - # Keep vim-devicons as last entry - vim-devicons; - }; - - # ========= Mapleader ========= - globals.mapleader = ";"; - - # - # ========= Key binds ========= - # - keymaps = [ - # Switching windows - { - mode = [ "n" ]; - action = "h"; - key = ""; - options = { - silent = true; - }; - } - { - mode = [ "n" ]; - action = "j"; - key = ""; - options = { - silent = true; - }; - } - { - mode = [ "n" ]; - action = "k"; - key = ""; - options = { - silent = true; - }; - } - { - mode = [ "n" ]; - action = "l"; - key = ""; - options = { - silent = true; - }; - } - # Toggle nvim-tree - { - mode = [ "n" ]; - action = "NvimTreeFindFileToggle"; - key = "tt"; - options = { - silent = true; - }; - } - { - # clear search highlighting - mode = [ "n" ]; - key = ""; - action = "nohlsearch"; - options = { noremap = true; }; - } - - # ========== Telescope Plugin ========= - { - # find files - mode = [ "n" ]; - key = "ff"; - action = "Telescope find_files"; - options = { noremap = true; }; - } - { - # live grep - mode = [ "n" ]; - key = "fg"; - action = "Telescope live_grep"; - options = { noremap = true; }; - } - { - # buffers - mode = [ "n" ]; - key = "fb"; - action = "Telescope buffers"; - options = { noremap = true; }; - } - { - # help tags - mode = [ "n" ]; - key = "fh"; - action = "Telescope help_tags"; - options = { noremap = true; }; - } - - ]; - extraConfigVim = '' - " ================ Persistent Undo ================== - " Keep undo history across sessions, by storing in file. - " Only works all the time. - if has('persistent_undo') - silent !mkdir ~/.vim/backups > /dev/null 2>&1 - set undodir=~/.vim/backups - set undofile - endif - - " ================ Vim Wiki config ================= - " See :h vimwiki_list for info on registering wiki paths - let wiki_0 = {} - let wiki_0.path = '~/dotfiles.wiki/' - let wiki_0.index = 'home' - let wiki_0.syntax = 'markdown' - let wiki_0.ext = '.md' - - " fill spaces in page names with _ in pathing - let wiki_0.links_space_char = '_' - - " ================ Ale ======================== - " linter and fixer packages have to be installed via AUR or pamac - let g:ale_linters = { - \ 'c': ['clang-tidy'], - \ 'python': ['flake8'], - \ 'vim': ['vint'], - \ 'markdown': ['markdownlint'], - \ } - - let g:ale_fixers = { - \ 'c': ['clang-format'], - \ 'javascript': ['prettier', 'eslint'], - \ 'json': ['fixjson', 'prettier'], - \ 'python': ['black', 'isort'], - \ } - - " Set global fixers for all file types except Markdown - " Why? because double spaces at the end of a line in markdown indicate a - " linebreak without creating a new paragraph - function! SetGlobalFixers() - let g:ale_fixers['*'] = ['trim_whitespace', 'remove_trailing_lines'] - endfunction - - augroup GlobalFixers - autocmd! - autocmd VimEnter * call SetGlobalFixers() - augroup END - - " Set buffer-local fixers for Markdown files - augroup MarkdownFixers - autocmd! - autocmd FileType markdown let b:ale_fixers = ['prettier'] - augroup END - - let g:ale_fix_on_save = 1 - ''; - - }; -} diff --git a/home/common/core/nixvim/default.nix b/home/common/core/nixvim/default.nix new file mode 100644 index 0000000..9974999 --- /dev/null +++ b/home/common/core/nixvim/default.nix @@ -0,0 +1,43 @@ +{ inputs, pkgs, ... }: { + imports = [ + inputs.nixvim.homeManagerModules.nixvim + ./plugins + ./options.nix + ./theme.nix + ./keymaps.nix + ]; + + # Install home packages needed for nixvim + home.packages = builtins.attrValues { + inherit (pkgs) + nixpkgs-fmt + prettierd + ;}; + + programs.nixvim = { + enable = true; + enableMan = true; # install man pages for nixvim options + clipboard.register = "unnamedplus"; # use system clipboard instead of internal registers + globals.mapleader = ";"; + + extraConfigVim = '' + " ================ Persistent Undo ================== + " Keep undo history across sessions, by storing in file. + " Only works all the time. + if has('persistent_undo') + silent !mkdir ~/.vim/backups > /dev/null 2>&1 + set undodir=~/.vim/backups + set undofile + endif + + " ================ Vim Wiki config ================= + " See :h vimwiki_list for info on registering wiki paths + let wiki_0 = {} + let wiki_0.path = '~/docs/wiki/' + let wiki_0.index = 'home' + let wiki_0.syntax = 'markdown' + let wiki_0.ext = '.md' + ''; + + }; +} diff --git a/home/common/core/nixvim/keymaps.nix b/home/common/core/nixvim/keymaps.nix new file mode 100644 index 0000000..a206604 --- /dev/null +++ b/home/common/core/nixvim/keymaps.nix @@ -0,0 +1,85 @@ +{ + programs.nixvim.keymaps = [ + # Switching buffers + { + mode = [ "n" ]; + action = "h"; + key = ""; + options = { + silent = true; + }; + } + { + mode = [ "n" ]; + action = "j"; + key = ""; + options = { + silent = true; + }; + } + { + mode = [ "n" ]; + action = "k"; + key = ""; + options = { + silent = true; + }; + } + { + mode = [ "n" ]; + action = "l"; + key = ""; + options = { + silent = true; + }; + } + + # Toggle nvim-tree + { + mode = [ "n" ]; + action = "NvimTreeFindFileToggle"; + key = "tt"; + options = { + silent = true; + }; + } + + # Clear search highlighting + { + mode = [ "n" ]; + key = ""; + action = "nohlsearch"; + options = { noremap = true; }; + } + + # Telescope Plugin + { + # find files + mode = [ "n" ]; + key = "ff"; + action = "Telescope find_files"; + options = { noremap = true; }; + } + { + # live grep + mode = [ "n" ]; + key = "fg"; + action = "Telescope live_grep"; + options = { noremap = true; }; + } + { + # buffers + mode = [ "n" ]; + key = "fb"; + action = "Telescope buffers"; + options = { noremap = true; }; + } + { + # help tags + mode = [ "n" ]; + key = "fh"; + action = "Telescope help_tags"; + options = { noremap = true; }; + } + ]; +} diff --git a/home/common/core/nixvim/options.nix b/home/common/core/nixvim/options.nix new file mode 100644 index 0000000..4b11f93 --- /dev/null +++ b/home/common/core/nixvim/options.nix @@ -0,0 +1,35 @@ +{ + programs.nixvim.opts = { + background = ""; + number = true; # show line numbers + relativenumber = true; # show relative linenumbers + laststatus = 0; # Display status line always + history = 1000; # Store lots of :cmdline history + showcmd = true; # Show incomplete cmds down the bottom + showmode = true; # Show current mode down the bottom + autoread = true; # Reload files changed outside vim + lazyredraw = true; # Redraw only when needed + showmatch = true; # highlight matching braces + ruler = true; # show current line and column + visualbell = true; # No sounds + listchars = "trail:·"; # Display tabs and trailing spaces visually + autoindent = true; + cindent = true; # automatically indent braces + smartindent = true; + smarttab = true; + shiftwidth = 2; + softtabstop = 4; + tabstop = 2; + expandtab = true; + wildmode = "list:longest"; + wildmenu = true; # enable ctrl-n and ctrl-p to scroll thru matches + scrolloff = 4; # Start scrolling when we're 4 lines away from margins + sidescrolloff = 15; + sidescroll = 1; + incsearch = true; + hlsearch = true; + ignorecase = true; + smartcase = true; + backspace = "indent,eol,start"; # allow backspace in insert mode + }; +} diff --git a/home/common/core/nixvim/plugins/colorizer.nix b/home/common/core/nixvim/plugins/colorizer.nix new file mode 100644 index 0000000..1022d83 --- /dev/null +++ b/home/common/core/nixvim/plugins/colorizer.nix @@ -0,0 +1,6 @@ +{ + programs.nixvim.plugins.nvim-colorizer = { + enable = true; + fileTypes = [ "*" ]; + }; +} diff --git a/home/common/core/nixvim/plugins/conform.nix b/home/common/core/nixvim/plugins/conform.nix new file mode 100644 index 0000000..7e27ea0 --- /dev/null +++ b/home/common/core/nixvim/plugins/conform.nix @@ -0,0 +1,21 @@ +{ + programs.nixvim.plugins.conform-nvim = { + enable = true; + formatOnSave = { + lspFallback = true; + timeoutMs = 500; + }; + notifyOnError = true; + formattersByFt = { + html = [["prettierd" "prettier"]]; + css = [["prettierd" "prettier"]]; + javascript = [["prettierd" "prettier"]]; + python = ["black"]; + lua = ["stylua"]; + nix = ["alejandra"]; + markdown = [["prettierd" "prettier"]]; + yaml = ["yamllint" "yamlfmt"]; + sql = ["sqlfmt"]; + }; + }; +} diff --git a/home/common/core/nixvim/plugins/default.nix b/home/common/core/nixvim/plugins/default.nix new file mode 100644 index 0000000..10fac20 --- /dev/null +++ b/home/common/core/nixvim/plugins/default.nix @@ -0,0 +1,30 @@ +{ pkgs, ... }: +{ + imports = [ + ./colorizer.nix + ./conform.nix + ./gitsigns.nix + ./harpoon.nix + ./lsp.nix + ./lualine.nix + ./nvim-tree.nix + ./surround.nix + ./telescope.nix + ./treesitter.nix + ]; + + # Load Plugins that aren't provided as modules by nixvim + programs.nixvim.extraPlugins = builtins.attrValues { + inherit (pkgs.vimPlugins) + ale + vim-numbertoggle + vimwiki + vim-dadbod + vim-dadbod-ui + + # Keep vim-devicons as last entry + vim-devicons; + }; + +} + diff --git a/home/common/core/nixvim/plugins/gitsigns.nix b/home/common/core/nixvim/plugins/gitsigns.nix new file mode 100644 index 0000000..d488015 --- /dev/null +++ b/home/common/core/nixvim/plugins/gitsigns.nix @@ -0,0 +1,35 @@ +{ + programs.nixvim.plugins.gitsigns = { + enable = true; + settings.signs.add = { + hl = "GitSignsAdd"; + text = " ▎"; + numhl = "GitSignsAddNr"; + linehl = "GitSignsAddLn"; + }; + settings.signs.change = { + hl = "GitSignsChange"; + text = " ▎"; + numhl = "GitSignsChangeNr"; + linehl = "GitSignsChangeLn"; + }; + settings.signs.delete = { + hl = "GitSignsDelete"; + text = " ●"; + numhl = "GitSignsDeleteNr"; + linehl = "GitSignsDeleteLn"; + }; + settings.signs.topdelete = { + hl = "GitSignsDelete"; + text = " ●"; + numhl = "GitSignsDeleteNr"; + linehl = "GitSignsDeleteLn"; + }; + settings.signs.changedelete = { + hl = "GitSignsChange"; + text = " ▎"; + numhl = "GitSignsChangeNr"; + linehl = "GitSignsChangeLn"; + }; + }; +} diff --git a/home/common/core/nixvim/plugins/harpoon.nix b/home/common/core/nixvim/plugins/harpoon.nix new file mode 100644 index 0000000..1462b1e --- /dev/null +++ b/home/common/core/nixvim/plugins/harpoon.nix @@ -0,0 +1,8 @@ +{ + programs.nixvim.plugins.harpoon = { + enable = true; + keymaps = { + toggleQuickMenu = "b"; + }; + }; +} diff --git a/home/common/core/nixvim/plugins/lsp.nix b/home/common/core/nixvim/plugins/lsp.nix new file mode 100644 index 0000000..9e6c7d2 --- /dev/null +++ b/home/common/core/nixvim/plugins/lsp.nix @@ -0,0 +1,51 @@ +{ + programs.nixvim.plugins.lsp = { + enable = true; + servers = { + lua-ls = {enable = true;}; + nixd = {enable = true;}; + bashls = {enable = true;}; + pyright = {enable = true;}; + html = {enable = true;}; + yamlls = {enable = true;}; + marksman = {enable = true;}; + #sqls = {enable = true;}; + }; + keymaps = { + 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"; + }; + "cw" = { + action = "workspace_symbol"; + desc = "Workspace Symbol"; + }; + "cr" = { + action = "rename"; + desc = "Rename"; + }; + }; + }; + }; +} diff --git a/home/common/core/nixvim/plugins/lspkind.nix b/home/common/core/nixvim/plugins/lspkind.nix new file mode 100644 index 0000000..8d7e15a --- /dev/null +++ b/home/common/core/nixvim/plugins/lspkind.nix @@ -0,0 +1,13 @@ +{ + # Add tiny pictograms to lsp + programs.nixvim.plugins.lspkind = { + enable = true; + symbolMap = { + Copilot = ""; + }; + extraOptions = { + maxwidth = 50; + ellipsis_char = "..."; + }; + }; +} diff --git a/home/common/core/nixvim/plugins/lualine.nix b/home/common/core/nixvim/plugins/lualine.nix new file mode 100644 index 0000000..f450ec9 --- /dev/null +++ b/home/common/core/nixvim/plugins/lualine.nix @@ -0,0 +1,22 @@ +{ + programs.nixvim.plugins.lualine = { + enable = true; + theme = "auto"; + componentSeparators = { + left = ""; + right = ""; + }; + sectionSeparators = { + left = ""; + right = ""; + }; + sections = { + lualine_a = [ "mode" ]; + lualine_b = [ "branch" "diff" "diagnostics" ]; + lualine_c = [ "filename" ]; + lualine_x = [ "encoding" "fileformat" "filetype" ]; + lualine_y = [ "progress" ]; + lualine_z = [ "locations" ]; + }; + }; +} diff --git a/home/common/core/nixvim/plugins/nvim-tree.nix b/home/common/core/nixvim/plugins/nvim-tree.nix new file mode 100644 index 0000000..1b55649 --- /dev/null +++ b/home/common/core/nixvim/plugins/nvim-tree.nix @@ -0,0 +1,12 @@ +{ + programs.nixvim.plugins.nvim-tree = { + enable = true; + view.width = { + min = 30; + max = -1; + padding = 1; + }; + disableNetrw = true; + filters.dotfiles = true; + }; +} diff --git a/home/common/core/nixvim/plugins/surround.nix b/home/common/core/nixvim/plugins/surround.nix new file mode 100644 index 0000000..cfee34b --- /dev/null +++ b/home/common/core/nixvim/plugins/surround.nix @@ -0,0 +1,3 @@ +{ + programs.nixvim.plugins.surround.enable = true; # vim-surround +} diff --git a/home/common/core/nixvim/plugins/telescope.nix b/home/common/core/nixvim/plugins/telescope.nix new file mode 100644 index 0000000..9582b09 --- /dev/null +++ b/home/common/core/nixvim/plugins/telescope.nix @@ -0,0 +1,6 @@ +{ + programs.nixvim.plugins.telescope = { + enable = true; + extensions.fzy-native.enable = true; + }; +} diff --git a/home/common/core/nixvim/plugins/treesitter.nix b/home/common/core/nixvim/plugins/treesitter.nix new file mode 100644 index 0000000..511d73a --- /dev/null +++ b/home/common/core/nixvim/plugins/treesitter.nix @@ -0,0 +1,5 @@ +{ + programs.nixvim.plugins.treesitter = { + enable = true; + }; +} diff --git a/home/common/core/nixvim/theme.nix b/home/common/core/nixvim/theme.nix new file mode 100644 index 0000000..82e5781 --- /dev/null +++ b/home/common/core/nixvim/theme.nix @@ -0,0 +1,15 @@ +{ + programs.nixvim.colorschemes.kanagawa = { + enable = true; + settings = { + commentStyle = { + italic = true; + }; + dimInactive = true; + terminalColors = true; + theme = "wave"; + transparent = false; + undercurl = true; + }; + }; +} diff --git a/home/common/optional/desktop/common/default.nix b/home/common/optional/desktop/common/default.nix index 3c8fb38..037c9d6 100644 --- a/home/common/optional/desktop/common/default.nix +++ b/home/common/optional/desktop/common/default.nix @@ -3,13 +3,13 @@ ./firefox.nix ./alacritty.nix ]; + # Global packages for desktop environments home.packages = [ pkgs.alacritty pkgs.libnotify pkgs.zathura pkgs.xfce.thunar - pkgs.wofi pkgs.kcolorchooser ]; } diff --git a/home/common/optional/desktop/hyprland/default.nix b/home/common/optional/desktop/hyprland/default.nix index 689b2eb..3a711a6 100644 --- a/home/common/optional/desktop/hyprland/default.nix +++ b/home/common/optional/desktop/hyprland/default.nix @@ -6,10 +6,8 @@ }: { imports = [ - ../wallpaper-changer/swww-wallpaper-changer ../common - ../waybar.nix - ../mako.nix + ../wayland ]; wayland.windowManager.hyprland = { enable = true; diff --git a/home/common/optional/desktop/wayland/default.nix b/home/common/optional/desktop/wayland/default.nix new file mode 100644 index 0000000..c7e1bc7 --- /dev/null +++ b/home/common/optional/desktop/wayland/default.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: +{ + imports = [ + ./mako.nix + ./waybar.nix + ./swww-wallpaper-changer.nix + ]; + + home.packages = [ + pkgs.wofi + pkgs.wl-clipboard + ]; +} diff --git a/home/common/optional/desktop/mako.nix b/home/common/optional/desktop/wayland/mako.nix similarity index 100% rename from home/common/optional/desktop/mako.nix rename to home/common/optional/desktop/wayland/mako.nix diff --git a/home/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix b/home/common/optional/desktop/wayland/swww-wallpaper-changer.nix similarity index 100% rename from home/common/optional/desktop/wallpaper-changer/swww-wallpaper-changer/default.nix rename to home/common/optional/desktop/wayland/swww-wallpaper-changer.nix diff --git a/home/common/optional/desktop/waybar.nix b/home/common/optional/desktop/wayland/waybar.nix similarity index 100% rename from home/common/optional/desktop/waybar.nix rename to home/common/optional/desktop/wayland/waybar.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index 4c7e6bb..b8a775a 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -2,5 +2,5 @@ # You can build them using 'nix build .#example' pkgs: { sddm-theme = pkgs.callPackage ./sddm-theme { }; - wallpaper_changer = pkgs.callPackage ./wallpaper-changer { }; + sqlfmt = pkgs.callPackage ./sqlfmt.nix { }; } diff --git a/pkgs/sqlfmt.nix b/pkgs/sqlfmt.nix new file mode 100644 index 0000000..74238d2 --- /dev/null +++ b/pkgs/sqlfmt.nix @@ -0,0 +1,25 @@ +{ pkgs, fetchFromGitHub, }: + +pkgs.stdenv.mkDerivation { + name = "sqlfmt-v0.21.3"; + src = fetchFromGitHub { + owner = "tconbeer"; + repo = "sqlfmt"; + rev = "v0.21.3"; + sha256 = "1sx8gf13pwsw63v5hfnml18fs2lnb2piigc1d4q8hmiywzmhzf85"; + }; + +#buildInputs = [ pkgs.python3 pkgs.isort pkgs.black pkgs.python311Packages.pytest pkgs.python311Packages.flake8 pkgs.python311Packages.mypy ]; + buildInputs = [ pkgs.python3 pkgs.python311Packages.pip pkgs.isort pkgs.black pkgs.python311Packages.pytest pkgs.python311Packages.flake8 pkgs.python311Packages.mypy ]; + + installPhase = '' + export PYTHONPATH="$\{python.sitePackages}:$PYTHONPATH" + $\{python}/bin/pip install --prefix $out . + ''; + + meta = { + description = "sqlfmt is a tool that autoformats your SQL queries."; + homepage = "https://github.com/tconbeer/sqlfmt"; + license = "Apache 2.0"; + }; +}