From 31df2f1a03e913915ec3cbdc06ac54c799ab7c1e Mon Sep 17 00:00:00 2001 From: "Lennart J. Kurzweg (Nx2)" Date: Mon, 29 Apr 2024 16:09:43 +0200 Subject: [PATCH] neovim start --- flake.lock | 63 ++++------ flake.nix | 22 ++-- home-modules/hyprland.nix | 30 ++--- home-modules/nixvim.nix | 128 ++++++++++++++++++++ home-modules/nvim-lua/options.lua | 18 +++ home-modules/nvim-lua/plugin/cmp.lua | 46 +++++++ home-modules/nvim-lua/plugin/lsp.lua | 48 ++++++++ home-modules/nvim-lua/plugin/other.lua | 11 ++ home-modules/nvim-lua/plugin/telescope.lua | 13 ++ home-modules/nvim-lua/plugin/treesitter.lua | 9 ++ home-modules/nvim.nix | 97 +++++++++++++++ home-modules/waybar.nix | 18 ++- home.nix | 3 + 13 files changed, 439 insertions(+), 67 deletions(-) create mode 100644 home-modules/nixvim.nix create mode 100644 home-modules/nvim-lua/options.lua create mode 100644 home-modules/nvim-lua/plugin/cmp.lua create mode 100644 home-modules/nvim-lua/plugin/lsp.lua create mode 100644 home-modules/nvim-lua/plugin/other.lua create mode 100644 home-modules/nvim-lua/plugin/telescope.lua create mode 100644 home-modules/nvim-lua/plugin/treesitter.lua create mode 100644 home-modules/nvim.nix diff --git a/flake.lock b/flake.lock index 781aed0..ff9f0fa 100644 --- a/flake.lock +++ b/flake.lock @@ -1,25 +1,5 @@ { "nodes": { - "Hyprspace": { - "inputs": { - "hyprland": [ - "hyprland" - ] - }, - "locked": { - "lastModified": 1713738762, - "narHash": "sha256-wXMqOQosjblsdV3x0DzpH7qSBUs5hT5Ca6eZ2Xp8TOA=", - "owner": "KZDKM", - "repo": "Hyprspace", - "rev": "de3b1ccbf30498b6fcd42b36418e33a2c8c1405a", - "type": "github" - }, - "original": { - "owner": "KZDKM", - "repo": "Hyprspace", - "type": "github" - } - }, "home-manager": { "inputs": { "nixpkgs": [ @@ -27,11 +7,11 @@ ] }, "locked": { - "lastModified": 1712386041, - "narHash": "sha256-dA82pOMQNnCJMAsPG7AXG35VmCSMZsJHTFlTHizpKWQ=", + "lastModified": 1714043624, + "narHash": "sha256-Xn2r0Jv95TswvPlvamCC46wwNo8ALjRCMBJbGykdhcM=", "owner": "nix-community", "repo": "home-manager", - "rev": "d6bb9f934f2870e5cbc5b94c79e9db22246141ff", + "rev": "86853e31dc1b62c6eeed11c667e8cdd0285d4411", "type": "github" }, "original": { @@ -82,11 +62,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1713778289, - "narHash": "sha256-h3ufswObZ8qUxQewTc5L173ILfV6JBQ+IaN1aN9RPjY=", + "lastModified": 1714248933, + "narHash": "sha256-hACvj8q0ucxslZmHf7j6bYlxVeDkJleAW+sCHGv4+2k=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "e1644e91ead7cdef5d08bfe6a579c4478a816a8e", + "rev": "2e763764bfdaee2039961c6c220b5d6af31712d4", "type": "github" }, "original": { @@ -107,11 +87,11 @@ ] }, "locked": { - "lastModified": 1713607544, - "narHash": "sha256-nbqQmhvYbDVC/5YiZLSGj5r14cOk2k6TGPpP2TtCfhI=", + "lastModified": 1714219583, + "narHash": "sha256-s6yf/bsAum3sAXSxB5gDCHQoLMn5Skl9EWL8nvsXzog=", "owner": "hyprwm", "repo": "hyprland-plugins", - "rev": "9971fec974a9d94a2a1b1d68d5ada5fc59fec053", + "rev": "97e9d252ffec654cdc69a2cea8b63a172795706b", "type": "github" }, "original": { @@ -182,11 +162,11 @@ ] }, "locked": { - "lastModified": 1713730424, - "narHash": "sha256-MqYjTvQCxwuDIuAaqIEuyqserm5PYr0auiHHPuYFN/k=", + "lastModified": 1714171579, + "narHash": "sha256-eaWDIvt8ufUKKz3Lc2a3PyemLJG1m9RYlF+HP3hWbaw=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "7c9c8adfe7e424faa0c5ce6e8be90157fda53c06", + "rev": "126dad854f22fe30e6b82cd21808e76903d90ac5", "type": "github" }, "original": { @@ -197,11 +177,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1713537308, - "narHash": "sha256-XtTSSIB2DA6tOv+l0FhvfDMiyCmhoRbNB+0SeInZkbk=", + "lastModified": 1714076141, + "narHash": "sha256-Drmja/f5MRHZCskS6mvzFqxEaZMeciScCTFxWVLqWEY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5c24cf2f0a12ad855f444c30b2421d044120c66f", + "rev": "7bb2ccd8cdc44c91edba16c48d2c8f331fb3d856", "type": "github" }, "original": { @@ -213,11 +193,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1713714899, - "narHash": "sha256-+z/XjO3QJs5rLE5UOf015gdVauVRQd2vZtsFkaXBq2Y=", + "lastModified": 1714076141, + "narHash": "sha256-Drmja/f5MRHZCskS6mvzFqxEaZMeciScCTFxWVLqWEY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6143fc5eeb9c4f00163267708e26191d1e918932", + "rev": "7bb2ccd8cdc44c91edba16c48d2c8f331fb3d856", "type": "github" }, "original": { @@ -228,11 +208,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1713725259, - "narHash": "sha256-9ZR/Rbx5/Z/JZf5ehVNMoz/s5xjpP0a22tL6qNvLt5E=", + "lastModified": 1713995372, + "narHash": "sha256-fFE3M0vCoiSwCX02z8VF58jXFRj9enYUSTqjyHAjrds=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a5e4bbcb4780c63c79c87d29ea409abf097de3f7", + "rev": "dd37924974b9202f8226ed5d74a252a9785aedf8", "type": "github" }, "original": { @@ -243,7 +223,6 @@ }, "root": { "inputs": { - "Hyprspace": "Hyprspace", "home-manager": "home-manager", "hyprland": "hyprland", "hyprland-plugins": "hyprland-plugins", diff --git a/flake.nix b/flake.nix index 10fd9bb..9dc2595 100644 --- a/flake.nix +++ b/flake.nix @@ -9,7 +9,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - hyprland = { + hyprland ={ url = "github:hyprwm/Hyprland"; # inputs.nixpkgs.follows = "nixpkgs"; }; @@ -17,11 +17,15 @@ url = "github:hyprwm/hyprland-plugins"; inputs.hyprland.follows = "hyprland"; }; - Hyprspace = { - url = "github:KZDKM/Hyprspace"; - inputs.hyprland.follows = "hyprland"; - }; + # Hyprspace = { + # url = "github:KZDKM/Hyprspace"; + # inputs.hyprland.follows = "hyprland"; + # }; + # nixvim = { + # url = "github:nix-community/nixvim/nixos-23.11"; + # inputs.nixpkgs.follows = "nixpkgs"; + # }; }; @@ -126,12 +130,16 @@ homeConfigurations = { "${user}@NxXPS" = let host = "NxXPS"; in home-manager.lib.homeManagerConfiguration { inherit pkgs; - modules = [ ./home.nix ]; + modules = [ + ./home.nix + ]; extraSpecialArgs = { inherit inputs system user host allowed secrets pkgs-unstable rice nvidia; }; }; "${user}@NxNORTH" = let host = "NxNORTH"; in home-manager.lib.homeManagerConfiguration { inherit pkgs; - modules = [ ./home.nix ]; + modules = [ + ./home.nix + ]; extraSpecialArgs = { inherit inputs system user host allowed secrets pkgs-unstable rice nvidia; }; }; }; diff --git a/home-modules/hyprland.nix b/home-modules/hyprland.nix index 856cf71..de1eaf1 100644 --- a/home-modules/hyprland.nix +++ b/home-modules/hyprland.nix @@ -58,10 +58,10 @@ in xwayland.enable = true; systemd.enable = true; plugins = [ - # inputs.hyprland-plugins.packages.${pkgs.system}.hyprexpo + inputs.hyprland-plugins.packages.${pkgs.system}.hyprexpo # inputs.hyprfocus.packages.${pkgs.system}.hyprfocus # inputs.hycov.packages.${pkgs.system}.hycov - inputs.Hyprspace.packages.${pkgs.system}.Hyprspace + # inputs.Hyprspace.packages.${pkgs.system}.Hyprspace ]; settings = { @@ -349,8 +349,8 @@ in ## ROW 2: #bind = SUPER, TAB, hycov:toggleoverview - "SUPER, TAB, overview:toggle" - # "SUPER SHIFT, TAB, hyprexpo:expo, toggle" + # "SUPER, TAB, overview:toggle" + "SUPER, TAB, hyprexpo:expo, toggle" "ALT, TAB, focuscurrentorlast" "SUPER, Q, killactive" "SUPER, W, exec, waybar_mode set '󰈹 '" @@ -759,18 +759,18 @@ in - # plugin { - # hyprexpo { - # columns = 5 - # gap_size = ${builtins.toString rice.gap-size} - # bg_col = rgb(${rice.lib.nohash rice.color.background}) - # workspace_method = first 10 # [center/first] [workspace] e.g. first 1 or center m+1 + plugin { + hyprexpo { + columns = 5 + gap_size = ${builtins.toString rice.gap-size} + bg_col = rgb(${rice.lib.nohash rice.color.background}) + workspace_method = first 10 # [center/first] [workspace] e.g. first 1 or center m+1 - # enable_gesture = false # laptop touchpad, 4 fingers - # gesture_distance = 300 # how far is the "max" - # gesture_positive = true # positive = swipe down. Negative = swipe up. - # } - # } + enable_gesture = false # laptop touchpad, 4 fingers + gesture_distance = 300 # how far is the "max" + gesture_positive = true # positive = swipe down. Negative = swipe up. + } + } plugin { diff --git a/home-modules/nixvim.nix b/home-modules/nixvim.nix new file mode 100644 index 0000000..5aad9de --- /dev/null +++ b/home-modules/nixvim.nix @@ -0,0 +1,128 @@ +{ config, pkgs, inputs, system, rice, ... }: +{ + imports = [ + inputs.nixvim.homeManagerModules.nixvim + ]; + + home.packages = [ + pkgs.neovide + ]; + programs.nixvim = { + enable = true; + viAlias = true; + vimAlias = true; + clipboard.providers.wl-copy.enable = true; + + options = { + number = true; + relativenumber = true; + shiftwidth = 2; + }; + colorschemes.catppuccin = { + enable = true; + settings = { + mocha = { + base = "#ff0000"; + }; + disable_underline = true; + flavour = "mocha"; + integrations = { + cmp = true; + gitsigns = true; + mini = { + enabled = true; + indentscope_color = ""; + }; + notify = false; + nvimtree = true; + treesitter = true; + }; + styles = { + booleans = [ + "bold" + "italic" + ]; + conditionals = [ + "bold" + ]; + }; + term_colors = true; + }; + }; + # colorschemes.base16 = { + # enable = true; + # setUpBar = true; + # colorscheme = "onedark"; + + # customColorScheme = { + # base00 = rice.color.background; + # base01 = rice.color.bright-black; + # base02 = rice.color.blue; + # base03 = rice.color.bright-blue; + # base04 = rice.color.cyan; + # base05 = rice.color.bright-cyan; + # base06 = rice.color.green; + # base07 = rice.color.bright-green; + # base08 = rice.color.magenta; + # base09 = rice.color.bright-magenta; + # base0A = rice.color.red; + # base0B = rice.color.bright-red; + # base0C = rice.color.white; + # base0D = rice.color.bright-white; + # base0E = rice.color.yellow; + # base0F = rice.color.bright-yellow; + # }; + # }; + opts = { + termguicolors = true; + }; + globals = { + mapleader = " "; + }; + plugins = { + telescope = { + enable = true; + extensions = { + fzf-native.enable = true; + }; + keymaps = { + "" = { action = "find_files"; }; + "fg" = { action = "live_grep"; }; + }; + }; + + lightline = { + enable = true; + # colorscheme = "base16"; + # active = { + # left = [ + # ["mode" "paste"] + # ["readonly" "filename" "modified"] + # ]; + + # right = [ + # [ "lineinfo" ] + # [ "percent" ] + # [ "fileformat" "fileencoding" "filetype" "charvaluehex" ] + # [ "git" ] + # ]; + # }; + }; + nix.enable = true; + + lsp-lines.enable = true; + lspkind.enable = true; + }; + extraPlugins = [ ]; + keymaps = + let + mkKeymap = mode: key: action: { inherit mode key action; }; + mkKeymapWithOpts = mode: key: action: opts: (mkKeymap mode key action) // { options = opts; }; + in + [ + (mkKeymap "" "" "") + (mkKeymap "n" "ff" "builtin.find_files") + ]; + }; +} +## vl clipboard? diff --git a/home-modules/nvim-lua/options.lua b/home-modules/nvim-lua/options.lua new file mode 100644 index 0000000..c7fa617 --- /dev/null +++ b/home-modules/nvim-lua/options.lua @@ -0,0 +1,18 @@ +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +vim.o.clipboard = 'unnamedplus' + +vim.o.number = true +-- vim.o.relativenumber = true + +vim.o.signcolumn = 'yes' + +vim.o.tabstop = 4 +vim.o.shiftwidth = 4 + +vim.o.updatetime = 300 + +vim.o.termguicolors = true + +vim.o.mouse = 'a' diff --git a/home-modules/nvim-lua/plugin/cmp.lua b/home-modules/nvim-lua/plugin/cmp.lua new file mode 100644 index 0000000..cf2b7a7 --- /dev/null +++ b/home-modules/nvim-lua/plugin/cmp.lua @@ -0,0 +1,46 @@ +local cmp = require('cmp') +local luasnip = require('luasnip') + +require('luasnip.loaders.from_vscode').lazy_load() +luasnip.config.setup {} + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete {}, + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, +} diff --git a/home-modules/nvim-lua/plugin/lsp.lua b/home-modules/nvim-lua/plugin/lsp.lua new file mode 100644 index 0000000..a65c1b2 --- /dev/null +++ b/home-modules/nvim-lua/plugin/lsp.lua @@ -0,0 +1,48 @@ +local on_attach = function(_, bufnr) + + local bufmap = function(keys, func) + vim.keymap.set('n', keys, func, { buffer = bufnr }) + end + + bufmap('r', vim.lsp.buf.rename) + bufmap('a', vim.lsp.buf.code_action) + + bufmap('gd', vim.lsp.buf.definition) + bufmap('gD', vim.lsp.buf.declaration) + bufmap('gI', vim.lsp.buf.implementation) + bufmap('D', vim.lsp.buf.type_definition) + + bufmap('gr', require('telescope.builtin').lsp_references) + bufmap('s', require('telescope.builtin').lsp_document_symbols) + bufmap('S', require('telescope.builtin').lsp_dynamic_workspace_symbols) + + bufmap('K', vim.lsp.buf.hover) + + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.lsp.buf.format() + end, {}) +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) + +require('neodev').setup() +require('lspconfig').lua_ls.setup { + on_attach = on_attach, + capabilities = capabilities, + root_dir = function() + return vim.loop.cwd() + end, + cmd = { "lua-lsp" }, + settings = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + }, + } +} + +require('lspconfig').rnix.setup { + on_attach = on_attach, + capabilities = capabilities, +} diff --git a/home-modules/nvim-lua/plugin/other.lua b/home-modules/nvim-lua/plugin/other.lua new file mode 100644 index 0000000..34ff92e --- /dev/null +++ b/home-modules/nvim-lua/plugin/other.lua @@ -0,0 +1,11 @@ +-- Lualine +require("lualine").setup({ + icons_enabled = true, + theme = 'onedark', +}) + +-- Colorscheme +vim.cmd("colorscheme gruvbox") + +-- Comment +require("Comment").setup() diff --git a/home-modules/nvim-lua/plugin/telescope.lua b/home-modules/nvim-lua/plugin/telescope.lua new file mode 100644 index 0000000..cf06b27 --- /dev/null +++ b/home-modules/nvim-lua/plugin/telescope.lua @@ -0,0 +1,13 @@ +require('telescope').setup({ + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + -- the default case_mode is "smart_case" + } + } +}) + +require('telescope').load_extension('fzf') diff --git a/home-modules/nvim-lua/plugin/treesitter.lua b/home-modules/nvim-lua/plugin/treesitter.lua new file mode 100644 index 0000000..2edb953 --- /dev/null +++ b/home-modules/nvim-lua/plugin/treesitter.lua @@ -0,0 +1,9 @@ +require('nvim-treesitter.configs').setup { + ensure_installed = {}, + + auto_install = false, + + highlight = { enable = true }, + + indent = { enable = true }, +} diff --git a/home-modules/nvim.nix b/home-modules/nvim.nix new file mode 100644 index 0000000..49f5256 --- /dev/null +++ b/home-modules/nvim.nix @@ -0,0 +1,97 @@ +{ config, pkgs, rice, ... }: +let + toLua = str: "lua << EOF\n${str}\nEOF\n"; + toLuaFile = file: "lua << EOF\n${builtins.readFile file}\nEOF\n"; +in +{ + programs.neovim = { + enable = true; + + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + + extraPackages = with pkgs; [ + lua-language-server + # rnix-lsp + + xclip + wl-clipboard + ]; + + plugins = with pkgs.vimPlugins; [ + + { + plugin = nvim-lspconfig; + config = toLuaFile ./nvim-lua/plugin/lsp.lua; + } + + { + plugin = comment-nvim; + config = toLua ''require("Comment").setup()''; + } + + { + plugin = gruvbox-nvim; + config = "colorscheme gruvbox"; + } + + neodev-nvim + + nvim-cmp + { + plugin = nvim-cmp; + config = toLuaFile ./nvim-lua/plugin/cmp.lua; + } + + { + plugin = telescope-nvim; + config = toLuaFile ./nvim-lua/plugin/telescope.lua; + } + + telescope-fzf-native-nvim + + cmp_luasnip + cmp-nvim-lsp + + luasnip + friendly-snippets + + + lualine-nvim + nvim-web-devicons + + { + plugin = (nvim-treesitter.withPlugins (p: [ + p.tree-sitter-nix + p.tree-sitter-vim + p.tree-sitter-bash + p.tree-sitter-lua + p.tree-sitter-python + p.tree-sitter-json + ])); + config = toLuaFile ./nvim-lua/plugin/treesitter.lua; + } + + vim-nix + + # { + # plugin = vimPlugins.own-onedark-nvim; + # config = "colorscheme onedark"; + # } + ]; + + extraLuaConfig = '' + ${builtins.readFile ./nvim-lua/options.lua} + ''; + + # extraLuaConfig = '' + # ${builtins.readFile ./nvim-lua/options.lua} + # ${builtins.readFile ./nvim-lua/plugin/lsp.lua} + # ${builtins.readFile ./nvim-lua/plugin/cmp.lua} + # ${builtins.readFile ./nvim-lua/plugin/telescope.lua} + # ${builtins.readFile ./nvim-lua/plugin/treesitter.lua} + # ${builtins.readFile ./nvim-lua/plugin/other.lua} + # ''; + }; +} diff --git a/home-modules/waybar.nix b/home-modules/waybar.nix index 32be260..679b2ff 100644 --- a/home-modules/waybar.nix +++ b/home-modules/waybar.nix @@ -93,7 +93,8 @@ in active-only = false; }; "hyprland/window" = { - format = "${sep}{}"; + # format = "${sep}{}"; + format = "{}"; separate-outputs = true; }; "custom/cclock" = { @@ -124,8 +125,8 @@ in tooltip = false; format = "{icon}${sep}{capacity}%"; states = { - warning = 25; - critical = 10; + warning = 15; + critical = 5; }; format-icons = [ " " @@ -236,7 +237,18 @@ in #wireplumber.muted { color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.blue}); } + + #battery.warning:not(.charging) { + color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.green});; + } + + #battery.critical { + color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.red});; + background: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.bright-red}); + } + #battery.charging { color: rgb(${rice.lib.hex-to-rgb-comma-string rice.color.green}); } ''; + #battery.critical:not(.charging) { }; } diff --git a/home.nix b/home.nix index 3c6c070..65a2c44 100644 --- a/home.nix +++ b/home.nix @@ -24,6 +24,8 @@ ./home-modules/kitty.nix ./home-modules/shell/fish.nix ./home-modules/shell/starship.nix + # ./home-modules/nixvim.nix + ./home-modules/nvim.nix ./home-modules/shell/yazi.nix ./home-modules/shell/zoxide.nix ./home-modules/shell/nh.nix @@ -70,6 +72,7 @@ nodejs gnumake + cmake speedtest-go