diff --git a/alacritty.nix b/alacritty.nix deleted file mode 100644 index 33bbdf0..0000000 --- a/alacritty.nix +++ /dev/null @@ -1,73 +0,0 @@ -{ - scrolling.history = 3000; - font = { - normal.family = "FuraCode Nerd Font"; - size = 9.0; - }; - background_opacity = 0.95; - mouse = { - hide_when_typing = true; - url.modifiers = "Control"; - }; - - # NORD Theme: https://github.com/arcticicestudio/nord-alacritty - colors = { - primary = { - background = "#2e3440"; - foreground = "#d8dee9"; - dim_foreground = "#a5abb6"; - }; - cursor = { - text = "#2e3440"; - cursor = "#d8dee9"; - }; - vi_mode_cursor = { - text = "#2e3440"; - cursor = "#d8dee9"; - }; - selection = { - text = "CellForeground"; - background = "#4c566a"; - }; - search = { - matches = { - foreground = "CellForeground"; - background = "#88c0d0"; - }; - bar = { - background = "#434c5e"; - foreground = "#d8dee9"; - }; - }; - normal = { - black = "#3b4252"; - red = "#bf616a"; - green = "#a3be8c"; - yellow = "#ebcb8b"; - blue = "#81a1c1"; - magenta = "#b48ead"; - cyan = "#88c0d0"; - white = "#e5e9f0"; - }; - bright = { - black = "#4c566a"; - red = "#bf616a"; - green = "#a3be8c"; - yellow = "#ebcb8b"; - blue = "#81a1c1"; - magenta = "#b48ead"; - cyan = "#8fbcbb"; - white = "#eceff4"; - }; - dim = { - black = "#373e4d"; - red = "#94545d"; - green = "#809575"; - yellow = "#b29e75"; - blue = "#68809a"; - magenta = "#8c738c"; - cyan = "#6d96a5"; - white = "#aeb3bb"; - }; - }; -} diff --git a/config.nix b/config.nix new file mode 100644 index 0000000..69baf10 --- /dev/null +++ b/config.nix @@ -0,0 +1 @@ +{ allowUnfree = true; } diff --git a/configs/kak-lsp/kak-lsp.toml b/configs/kak-lsp/kak-lsp.toml new file mode 100644 index 0000000..022178e --- /dev/null +++ b/configs/kak-lsp/kak-lsp.toml @@ -0,0 +1,180 @@ +snippet_support = true +verbosity = 2 + + +[semantic_scopes] +# Map textmate scopes to kakoune faces for semantic highlighting +# the underscores are translated to dots, and indicate nesting. +# That is, if variable_other_field is omitted, it will try the face for +# variable_other and then variable +# +# To see a list of available scopes in the debug buffer, run lsp-semantic-available-scopes +variable = "variable" +entity_name_function = "function" +entity_name_type = "type" +variable_other_enummember = "variable" +entity_name_namespace = "module" + +# Semantic tokens support +# See https://github.com/microsoft/vscode-languageserver-node/blob/8c8981eb4fb6adec27bf1bb5390a0f8f7df2899e/client/src/semanticTokens.proposed.ts#L288 +# for token/modifier types. + +[semantic_tokens] +type = "type" +variable = "variable" +namespace = "module" +function = "function" +string = "string" +keyword = "keyword" +operator = "operator" +comment = "comment" + +[semantic_token_modifiers] +documentation = "documentation" +readonly = "default+d" + +[server] +# exit session if no requests were received during given period in seconds +# works only in unix sockets mode (-s/--session) +# set to 0 to disable +timeout = 1800 # seconds = 30 minutes + +[language.bash] +filetypes = ["sh", "zsh"] +roots = [".git", ".hg"] +command = "bash-language-server" +args = ["start"] + +[language.c_cpp] +filetypes = ["c", "cpp"] +roots = ["compile_commands.json", ".clangd"] +command = "clangd" + +[language.crystal] +filetypes = ["crystal"] +roots = ["shard.yml"] +command = "scry" + +[language.css] +filetypes = ["css"] +roots = ["package.json"] +command = "css-languageserver" +args = ["--stdio"] + +[language.d] +filetypes = ["d", "di"] +roots = [".git", "dub.sdl", "dub.json"] +command = "dls" + +[language.dart] +# start shell to find path to dart analysis server source +filetypes = ["dart"] +roots = ["pubspec.yaml", ".git"] +command = "sh" +args = ["-c", "dart $(dirname $(which dart))/snapshots/analysis_server.dart.snapshot --lsp"] + +[language.elm] +filetypes = ["elm"] +roots = ["elm.json"] +command = "elm-language-server" +args = ["--stdio"] + +[language.elm.initialization_options] +runtime = "node" +elmPath = "elm" +elmFormatPath = "elm-format" +elmTestPath = "elm-test" + +[language.go] +filetypes = ["go"] +roots = ["Gopkg.toml", "go.mod", ".git", ".hg"] +command = "gopls" +offset_encoding = "utf-8" + +[language.haskell] +filetypes = ["haskell"] +roots = ["Setup.hs", "stack.yaml", "*.cabal"] +# You might also be interested in the newer, but early stage, haskell-language-server +# https://github.com/haskell/haskell-language-server +command = "hie-wrapper" +args = ["--lsp"] + +[language.html] +filetypes = ["html"] +roots = ["package.json"] +command = "html-languageserver" +args = ["--stdio"] + +[language.javascript] +filetypes = ["javascript"] +roots = [".flowconfig"] +command = "flow" +args = ["lsp"] + +[language.json] +filetypes = ["json"] +roots = ["package.json"] +command = "json-languageserver" +args = ["--stdio"] + +[language.latex] +filetypes = ["latex"] +roots = [".git"] +command = "texlab" + +# [language.nim] +# filetypes = ["nim"] +# roots = ["*.nimble", ".git"] +# command = "nimlsp" + +[language.nix] +filetypes = ["nix"] +roots = ["flake.nix", "shell.nix", ".git"] +command = "rnix-lsp" + +# [language.ocaml] +# filetypes = ["ocaml"] +# roots = ["Makefile", "opam", "*.opam", "dune"] +# command = "ocaml-language-server" +# args = ["--stdio"] + +[language.php] +filetypes = ["php"] +roots = [".htaccess", "composer.json"] +command = "intelephense" +args = ["--stdio"] + +[language.php.initialization_options] +storagePath = "/tmp/intelephense" + +[language.python] +filetypes = ["python"] +roots = ["requirements.txt", "setup.py", ".git", ".hg"] +command = "pyls" +offset_encoding = "utf-8" + +# [language.reason] +# filetypes = ["reason"] +# roots = ["package.json", "Makefile", ".git", ".hg"] +# command = "ocaml-language-server" +# args = ["--stdio"] + +# [language.ruby] +# filetypes = ["ruby"] +# roots = ["Gemfile"] +# command = "solargraph" +# args = ["stdio"] + +[language.rust] +filetypes = ["rust"] +roots = ["Cargo.toml"] +#command = "sh" +#args = ["-c", "if command -v rustup >/dev/null; then $(rustup which rls); else rls; fi"] +command = "rust-analyzer" + +# [language.terraform] +# filetypes = ["terraform"] +# roots = ["*.tf"] +# command = "terraform-ls" +# args = ["serve"] + diff --git a/configs/themes/nord.nix b/configs/themes/nord.nix new file mode 100644 index 0000000..2a39040 --- /dev/null +++ b/configs/themes/nord.nix @@ -0,0 +1,18 @@ +{ + nord0 = "#2e3440"; + nord1 = "#3b4252"; + nord2 = "#434c5e"; + nord3 = "#4c566a"; + nord4 = "#d8dee9"; + nord5 = "#e5e9f0"; + nord6 = "#eceff4"; + nord7 = "#8fbcbb"; + nord8 = "#88c0d0"; + nord9 = "#81a1c1"; + nord10 = "#5e81ac"; + nord11 = "#bf616a"; + nord12 = "#d08770"; + nord13 = "#ebcb8b"; + nord14 = "#a3be8c"; + nord15 = "#b48ead"; +} diff --git a/home.nix b/home.nix index c5779e9..bf83a91 100644 --- a/home.nix +++ b/home.nix @@ -1,6 +1,8 @@ -{ pkgs, ... }: +{ lib, pkgs, ... }: -let unstable = import {}; +let + unstable = import {}; + colorscheme.theme = import ./packages/nord.nix; in { fonts.fontconfig = { enable = true; @@ -12,88 +14,35 @@ in { keyboard.options = ["terminate:ctrl_alt_bksp" "compose:rctrl"]; packages = with pkgs; [ nerdfonts + spotify + gnome3.nautilus + procps-ng + mmv-go ]; }; programs = { - alacritty = { - enable = false; - settings = import ./alacritty.nix; - }; + # alacritty = import ./modules/alacritty.nix pkgs; - bat = { - enable = true; - config = { - theme = "Nord"; - }; - }; + bat = { enable = true; config.theme = "Nord"; }; command-not-found.enable = true; - broot = { - enable = true; - enableBashIntegration = true; - enableZshIntegration = true; - }; + broot = { enable = true; enableBashIntegration = true; enableZshIntegration = true; }; - dircolors = { - enable = true; - enableBashIntegration = true; - enableZshIntegration = true; - }; + dircolors = { enable = true; enableBashIntegration = true; enableZshIntegration = true; }; - direnv = { - enable = true; - enableBashIntegration = true; - enableZshIntegration = true; - enableNixDirenvIntegration = true; - }; + direnv = { enable = true; enableBashIntegration = true; enableZshIntegration = true; enableNixDirenvIntegration = true; }; - git = - let kakouneCommand = "${pkgs.kakoune}/bin/kak"; - meldCommand = "${pkgs.meld}/bin/meld"; - in { - enable = true; - userName = "Filippo Berto"; - userEmail = "berto.f@protonmail.com"; - signing = { - key = "berto.f@protonmail.com"; - signByDefault = true; - }; - extraConfig = { - core.editor = kakouneCommand; - credential.helper = "cache --timeout=3600"; - diff.guitool = meldCommand; - merge.guitool = meldCommand; - pull.rebase = true; - rebase.autostash = true; - init.defaultBranch = "master"; - }; - lfs.enable = true; - delta.enable = true; - }; + git = import ./modules/git.nix pkgs; home-manager.enable = true; info.enable = true; - kakoune = { - enable = true; - config = import ./kakoune.nix pkgs; - extraConfig = builtins.concatStringsSep "\n" [ - "# Extra" - "define-command -docstring 'save and quit' x 'write-all; quit'" - "add-highlighter global/ regex \\h+$ 0:Error" - "eval %sh{kak-lsp --kakoune -s \$kak_session}" - "require-module auto-pairs" - "require-module powerline" - ]; - plugins = with pkgs; [ - kakounePlugins.kak-auto-pairs - unstable.kakounePlugins.powerline-kak - unstable.kakounePlugins.prelude-kak - ]; - }; + kakoune = import ./modules/kakoune.nix pkgs; + + rofi = import ./modules/rofi.nix pkgs; zsh = { enableVteIntegration = true; @@ -105,6 +54,10 @@ in { platformTheme = "gtk"; }; + services = { + # sxhkd = import ./modules/sxhkd.nix pkgs; + }; + xsession.numlock.enable = true; } diff --git a/kakoune.nix b/kakoune.nix deleted file mode 100644 index f54fc7b..0000000 --- a/kakoune.nix +++ /dev/null @@ -1,131 +0,0 @@ -{pkgs, ...} : - -{ - colorScheme = "nord"; - tabStop = 2; - indentWidth = 2; - scrollOff = { - lines = 5; - columns = 3; - }; - ui = { - setTitle = true; - changeColors = true; - enableMouse = true; - }; - wrapLines = { - enable = true; - word = true; - }; - numberLines = { - enable = true; - highlightCursor = true; - }; - keyMappings = [{ - mode = "normal"; - docstring = "Open file"; - key = ""; - effect = ":edit"; - } { - mode = "user"; - docstring = "Comment block"; - key = "b"; - effect = ":comment-block"; - } { - mode = "user"; - docstring = "Comment line"; - key = "l"; - effect = ":comment-line"; - } { - mode = "user"; - docstring = "Show hover info"; - key = "q"; - effect = ":lsp-hover"; - } { - mode = "user"; - docstring = "Jump to definition"; - key = "d"; - effect = ":lsp-definition"; - } { - mode = "user"; - docstring = "List project diagnostics"; - key = "i"; - effect = ":lsp-diagnostics"; - } { - mode = "user"; - docstring = "Jump to type definition"; - key = "t"; - effect = ":lsp-type-definition"; - } { - mode = "user"; - docstring = "Code actions"; - key = "a"; - effect = ":lsp-code-actions"; - } { - mode = "user"; - docstring = "Format code"; - key = "F"; - effect = ":lsp-formatting-sync"; - } { - mode = "user"; - docstring = "Spellcheck"; - key = "s"; - effect = ":spell "; - } { - mode = "user"; - docstring = "Spellcheck English"; - key = "S"; - effect = ":spell en"; - } { - mode = "user"; - docstring = "Copy to clipboard"; - key = "y"; - effect = "${pkgs.xclip}/bin/xclip -i -selection clipboard"; - } { - mode = "user"; - docstring = "Paste from clipboard (before)"; - key = "p"; - effect = "!${pkgs.xclip}/bin/xclip -selection clipboard -o"; - } { - mode = "user"; - docstring = "Paste from clipboard (after)"; - key = "P"; - effect = "${pkgs.xclip}/bin/xclip -selection clipboard -o"; - }]; - hooks = [{ - name = "WinSetOption"; - option = "filetype=(rust|python|c|cpp|latex|javascript|go)"; - commands = builtins.concatStringsSep "\n" [ - "lsp-enable-window" - ]; - } { - name = "BufCreate"; - option = ".*"; - commands = "editorconfig-load"; - } { - name = "ModuleLoaded"; - option = "powerline"; - commands = builtins.concatStringsSep "\n" [ - # "powerline-theme default" - "powerline-enable" - ]; - } { - name = "ModuleLoaded"; - option = "auto-pairs"; - commands = "auto-pairs-enable"; - } { - name = "InsertCompletionShow"; - option = ".*"; - commands = builtins.concatStringsSep "\n" [ - "map window insert " - "map window insert " - ]; - } { - name = "InsertCompletionHide"; - option = ".*"; - commands = builtins.concatStringsSep "\n" [ - "unmap window insert " - "unmap window insert " - ]; - }]; -} diff --git a/modules/alacritty.nix b/modules/alacritty.nix new file mode 100644 index 0000000..4a17484 --- /dev/null +++ b/modules/alacritty.nix @@ -0,0 +1,78 @@ +{ config, pkgs, lib, ... }: + +{ + enable = true; + settings = { + scrolling.history = 3000; + font = { + normal.family = "FuraCode Nerd Font"; + size = 9.0; + }; + background_opacity = 0.95; + mouse = { + hide_when_typing = true; + url.modifiers = "Control"; + }; + + # NORD Theme: https://github.com/arcticicestudio/nord-alacritty + colors = { + primary = { + background = "#2e3440"; + foreground = "#d8dee9"; + dim_foreground = "#a5abb6"; + }; + cursor = { + text = "#2e3440"; + cursor = "#d8dee9"; + }; + vi_mode_cursor = { + text = "#2e3440"; + cursor = "#d8dee9"; + }; + selection = { + text = "CellForeground"; + background = "#4c566a"; + }; + search = { + matches = { + foreground = "CellForeground"; + background = "#88c0d0"; + }; + bar = { + background = "#434c5e"; + foreground = "#d8dee9"; + }; + }; + normal = { + black = "#3b4252"; + red = "#bf616a"; + green = "#a3be8c"; + yellow = "#ebcb8b"; + blue = "#81a1c1"; + magenta = "#b48ead"; + cyan = "#88c0d0"; + white = "#e5e9f0"; + }; + bright = { + black = "#4c566a"; + red = "#bf616a"; + green = "#a3be8c"; + yellow = "#ebcb8b"; + blue = "#81a1c1"; + magenta = "#b48ead"; + cyan = "#8fbcbb"; + white = "#eceff4"; + }; + dim = { + black = "#373e4d"; + red = "#94545d"; + green = "#809575"; + yellow = "#b29e75"; + blue = "#68809a"; + magenta = "#8c738c"; + cyan = "#6d96a5"; + white = "#aeb3bb"; + }; + }; + }; +} diff --git a/modules/git.nix b/modules/git.nix new file mode 100644 index 0000000..ff92f4a --- /dev/null +++ b/modules/git.nix @@ -0,0 +1,24 @@ +{ config, pkgs, lib, ... }: +let + kakouneCommand = "${pkgs.kakoune}/bin/kak"; + meldCommand = "${pkgs.meld}/bin/meld"; +in { + enable = true; + userName = "Filippo Berto"; + userEmail = "berto.f@protonmail.com"; + signing = { + key = "berto.f@protonmail.com"; + signByDefault = true; + }; + extraConfig = { + core.editor = kakouneCommand; + credential.helper = "cache --timeout=3600"; + diff.guitool = meldCommand; + merge.guitool = meldCommand; + pull.rebase = true; + rebase.autostash = true; + init.defaultBranch = "master"; + }; + lfs.enable = true; + delta.enable = true; +} diff --git a/modules/kakoune.nix b/modules/kakoune.nix new file mode 100644 index 0000000..4f7913a --- /dev/null +++ b/modules/kakoune.nix @@ -0,0 +1,148 @@ +{ config, lib, pkgs, ... }: +let + unstable = import {}; +in { + enable = true; + config = { + colorScheme = "nord"; + tabStop = 2; + indentWidth = 2; + scrollOff = { + lines = 5; + columns = 3; + }; + ui = { + setTitle = true; + changeColors = true; + enableMouse = true; + }; + wrapLines = { + enable = true; + word = true; + }; + numberLines = { + enable = true; + highlightCursor = true; + }; + keyMappings = [{ + mode = "normal"; + docstring = "Open file"; + key = ""; + effect = ":edit"; + } { + mode = "user"; + docstring = "Comment block"; + key = "b"; + effect = ":comment-block"; + } { + mode = "user"; + docstring = "Comment line"; + key = "l"; + effect = ":comment-line"; + } { + mode = "user"; + docstring = "Show hover info"; + key = "q"; + effect = ":lsp-hover"; + } { + mode = "user"; + docstring = "Jump to definition"; + key = "d"; + effect = ":lsp-definition"; + } { + mode = "user"; + docstring = "List project diagnostics"; + key = "i"; + effect = ":lsp-diagnostics"; + } { + mode = "user"; + docstring = "Jump to type definition"; + key = "t"; + effect = ":lsp-type-definition"; + } { + mode = "user"; + docstring = "Code actions"; + key = "a"; + effect = ":lsp-code-actions"; + } { + mode = "user"; + docstring = "Format code"; + key = "F"; + effect = ":lsp-formatting-sync"; + } { + mode = "user"; + docstring = "Spellcheck"; + key = "s"; + effect = ":spell "; + } { + mode = "user"; + docstring = "Spellcheck English"; + key = "S"; + effect = ":spell en"; + } { + mode = "user"; + docstring = "Copy to clipboard"; + key = "y"; + effect = "${pkgs.xclip}/bin/xclip -i -selection clipboard"; + } { + mode = "user"; + docstring = "Paste from clipboard (before)"; + key = "p"; + effect = "!${pkgs.xclip}/bin/xclip -selection clipboard -o"; + } { + mode = "user"; + docstring = "Paste from clipboard (after)"; + key = "P"; + effect = "${pkgs.xclip}/bin/xclip -selection clipboard -o"; + }]; + hooks = [{ + name = "WinSetOption"; + option = "filetype=(rust|python|c|cpp|latex|javascript|go)"; + commands = builtins.concatStringsSep "\n" [ + "lsp-enable-window" + ]; + } { + name = "BufCreate"; + option = ".*"; + commands = "editorconfig-load"; + } { + name = "ModuleLoaded"; + option = "powerline"; + commands = builtins.concatStringsSep "\n" [ + # "powerline-theme default" + "powerline-enable" + ]; + } { + name = "ModuleLoaded"; + option = "auto-pairs"; + commands = "auto-pairs-enable"; + } { + name = "InsertCompletionShow"; + option = ".*"; + commands = builtins.concatStringsSep "\n" [ + "map window insert " + "map window insert " + ]; + } { + name = "InsertCompletionHide"; + option = ".*"; + commands = builtins.concatStringsSep "\n" [ + "unmap window insert " + "unmap window insert " + ]; + }]; + }; + extraConfig = builtins.concatStringsSep "\n" [ + "# Extra" + "define-command -docstring 'save and quit' x 'write-all; quit'" + "add-highlighter global/ regex \\h+$ 0:Error" + "eval %sh{kak-lsp --kakoune -s \$kak_session}" + "require-module auto-pairs" + "require-module powerline" + ]; + plugins = with pkgs; [ + kakounePlugins.kak-auto-pairs + unstable.kakounePlugins.powerline-kak + unstable.kakounePlugins.prelude-kak + ]; +} diff --git a/modules/rofi.nix b/modules/rofi.nix new file mode 100644 index 0000000..9b263da --- /dev/null +++ b/modules/rofi.nix @@ -0,0 +1,8 @@ +{ config, pkgs, lib, ... }: + +{ + enable = true; + extraConfig = { + modi = "drun,run,ssh,window"; + }; +} diff --git a/modules/sxhkd.nix b/modules/sxhkd.nix new file mode 100644 index 0000000..e2bebc7 --- /dev/null +++ b/modules/sxhkd.nix @@ -0,0 +1,47 @@ +{ config, pkgs, lib, ... }: +let + sxhkd = "${pkgs.sxhkd}/bin/sxhkd"; + bspc = "${pkgs.bspwm}/bin/bspc"; + xarg = "${pkgs.xarg}/bin/xargs"; + nautilus = "${pkgs.gnome3.nautilus}/bin/nautilus"; + pulseaudioCtl = "${pkgs.pulseaudio-ctl}/bin/pulseaudio-ctl"; + playerctl = "${pkgs.playerctl}/bin/playerctl"; + alacritty = "${pkgs.alacritty}/bin/alacritty"; + rofi = "${pkgs.rofi}/bin/rofi"; + bash = "${pkgs.bash}/bin/bash"; +in { + enable = true; + keybindings = { + "super + Return" = "${bash} ${alacritty}"; + "super + @space" = "${rofi} -show drun"; + "super + e" = "${nautilus} -w"; + "super + Escape" = "pkill -USR1 -x sxhkd"; + "super + {_,shift + }w" = "${bspc} node -{c,k}"; + "super + m" = "${bspc} desktop -l next"; + "super + y" = "${bspc} node newest.marked.local -n newest.!automatic.local"; + "super + g" = "${bspc} node -s biggest"; + "super + {t,shift + t,s,f}" = "${bspc} node -t {tiled,pseudo_tiled,floating,fullscreen}"; + "super + ctrl + {m,x,y,z}" = "${bspc} node -g {marked,locked,sticky,private}"; + "super + {_,shift + }{h,j,k,l}" = "${bspc} node -{f,s} {west,south,north,east}"; + "super + {p,b,comma,period}" = "${bspc} node -f @{parent,brother,first,second}"; + "super + {_,shift + }c" = "${bspc} node -f {next,prev}.local"; + "super + bracket{left,right}" = "${bspc} desktop -f {prev,next}.local"; + "super + {grave,Tab}" = "${bspc} {node,desktop} -f last"; + "super + {o,i}" = "${bspc} wm -h off;${bspc} node {older,newer} -f;${bspc} wm -h on"; + "super + {_,shift + }{1-9,0}" = "${bspc} {desktop -f,node -d} 'focused:^{1-9,10}'"; + "super + ctrl + {h,j,k,l}" = "${bspc} node -p {west,south,north,east}"; + "super + ctrl + {1-9}" = "${bspc} node -o 0.{1-9}"; + "super + ctrl + space" = "${bspc} node -p cancel"; + "super + ctrl + shift + space" = "${bspc} query -N -d | xargs -I id -n 1 ${bspc} node id -p cancel"; + "super + alt + {h,j,k,l}" = "${bspc} node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0}"; + "super + alt + shift + {h,j,k,l}" = "${bspc} node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0}"; + "super + {Left,Down,Up,Right}" = "${bspc} node -v {-20 0,0 20,0 -20,20 0}"; + "XF86AudioRaiseVolume" = "${pulseaudioCtl} up"; + "XF86AudioLowerVolume" = "${pulseaudioCtl} down"; + "XF86AudioMute" = "${pulseaudioCtl} mute"; + "XF86AudioPlay" = "${playerctl} play-pause"; + "XF86AudioNext" = "${playerctl} next"; + "XF86AudioPrev" = "${playerctl} previous"; + }; +} +