diff --git a/flake.nix b/flake.nix index 1a8a063..4e57da9 100644 --- a/flake.nix +++ b/flake.nix @@ -68,7 +68,7 @@ devShells.default = pkgs.mkShell { buildInputs = [ - # deploy-rs.packages.${system}.deploy-rs + # deploy-rs.packages.${system}.deploy-rs pkgs.deploy-rs ]; shellHook = '' diff --git a/modules/hm/hyprland.nix b/modules/hm/hyprland.nix index 450456c..7897840 100644 --- a/modules/hm/hyprland.nix +++ b/modules/hm/hyprland.nix @@ -37,17 +37,17 @@ # See https://wiki.hyprland.org/Configuring/Monitors/ # monitor=name,resolution,position,scale monitor,preferred,auto,auto - ${ + ${ if nixosConfig.networking.hostName == "thor" then '' monitor=HDMI-A-1,preferred,0x0,auto,transform,3 monitor=DP-2,preferred,1080x420,auto - '' + '' else if nixosConfig.networking.hostName == "odin" then '' monitor=eDP-1,preferred,320x1440,1 monitor=DP-1,preferred,0x0,1 - '' + '' else "" } @@ -165,10 +165,10 @@ bind = SUPER, RETURN, exec, kitty bind = SUPER, W, killactive, bind = SUPER, M, exec, way-lockscreen - bind = SUPER_ALT_L, Q, exit, + bind = SUPER_ALT_L, Q, exit, bind = SUPER, E, exec, nautilus bind = SUPER_SHIFT, E, exec, nemo - bind = SUPER, V, togglefloating, + bind = SUPER, V, togglefloating, bind = SUPER_SHIFT, SPACE, exec, wofi --show run --allow-images -D key_expand=Tab -M=fuzzy -i bind = SUPER, SPACE, exec, wofi --show drun --allow-images -D key_expand=Tab -M=fuzzy -i bind = SUPER, F, fullscreen, diff --git a/modules/hm/nvim/nvim-cmp-config.lua b/modules/hm/nvim/nvim-cmp-config.lua new file mode 100644 index 0000000..1632223 --- /dev/null +++ b/modules/hm/nvim/nvim-cmp-config.lua @@ -0,0 +1,33 @@ +local cmp = require("cmp") +local luasnip = require("luasnip") + +-- loads vscode style snippets from installed plugins (eg. friendly-snippets) +require("luasnip.loaders.from_vscode").lazy_load() + +cmp.setup({ + completion = { + completeopt = "menu,menuone,preview,noselect" + }, + snippet = { -- configura how nvim-cmp interacts with snippet engine + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(), -- previous suggestion + [""] = cmp.mapping.select_next_item(), -- next suggestion + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), -- show completion suggestions + [""] = cmp.mapping.abort(), -- close cmpletion window + [""] = cmp.mapping.confirm({ select = false }) + }), + -- sources for autocompletion + sources = cmp.config.sources({ + { name = "nvim_lsp" }, -- nvim_lsp + { name = "luasnip" }, -- snippets + { name = "buffer" }, -- text within current buffer + { name = "path" }, -- file system paths + }), +}) + diff --git a/modules/hm/nvim/nvim-lspconfig.lua b/modules/hm/nvim/nvim-lspconfig.lua new file mode 100644 index 0000000..b926f3e --- /dev/null +++ b/modules/hm/nvim/nvim-lspconfig.lua @@ -0,0 +1,92 @@ +local lspconfig = require('lspconfig') +local capabilities = require("cmp_nvim_lsp").default_capabilities() + + +-- Keymaps +local keymap = vim.keymap +local opts = { noremap = true, silent = true } +local on_attach = function(client, bufnr) + opts.buffer = bufnr + + opts.desc = "Show LSP references" + keymap.set("n", "gR", "Telescope lsp_references", opts) + opts.desc = "Go to declaration" + keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + opts.desc = "Go to definition" + keymap.set("n", "gd", "Telescope lsp_definitions", opts) + opts.desc = "Show LSP implementations" + keymap.set("n", "gi", "Telescope lsp_implementations", opts) + opts.desc = "Show LSP type definitions" + keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) + opts.desc = "See available code actions" + keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) + opts.desc = "Smart rename" + keymap.set("n", "rn", vim.lsp.buf.rename, opts) + opts.desc = "Smart show buffer diagnostics" + keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) + opts.desc = "Smart show line diagnostics" + keymap.set("n", "d", vim.diagnostic.open_float, opts) + opts.desc = "Go to previous diagnostic" + keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) + opts.desc = "Go to next diagnostic" + keymap.set("n", "]d", vim.diagnostic.goto_next, opts) + opts.desc = "Show documentation for what is under cursor" + keymap.set("n", "K", vim.lsp.buf.hover, opts) + opts.desc = "Restart LSP" + keymap.set("n", "rs", ":LspRestart", opts) +end + +-- Change the Diagnostic symbols in the sign column (gutter) +-- (not in youtube nvim video) +local signs = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " " } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) +end + +-- LSP configuration +lspconfig["html"].setup { capabilities = capabilities, on_attach = on_attach} +lspconfig["pylsp"].setup { capabilities = capabilities, on_attach = on_attach} +lspconfig["nil_ls"].setup { capabilities = capabilities, on_attach = on_attach, settings = { + ["nil"] = { + formatting = { command = { "nixpkgs-fmt" } }, + autoEvalInputs = true + } +}} +lspconfig["rust_analyzer"].setup { capabilities = capabilities, on_attach = on_attach} +lspconfig["texlab"].setup { capabilities = capabilities, on_attach = on_attach, settings = { + texlab = { + formatterLineLength = 0, + bibtexFormatter = "latexindent", + latexindent = { modifyLineBreaks = false }, + chktex = { onEdit = true }, + } +}} +lspconfig["clangd"].setup { capabilities = capabilities, on_attach = on_attach} +lspconfig["marksman"].setup { capabilities = capabilities, on_attach = on_attach} +lspconfig["yamlls"].setup { capabilities = capabilities, on_attach = on_attach, settings = { + yaml = { + keyOrdering = false, + schemas = { + ["kubernetes"] = "*.yaml", + ["http://json.schemastore.org/github-workflow"] = ".github/workflows/*", + ["http://json.schemastore.org/github-action"] = ".github/action.{yml,yaml}", + ["http://json.schemastore.org/ansible-stable-2.9"] = "roles/tasks/*.{yml,yaml}", + ["http://json.schemastore.org/prettierrc"] = ".prettierrc.{yml,yaml}", + ["http://json.schemastore.org/kustomization"] = "kustomization.{yml,yaml}", + ["http://json.schemastore.org/ansible-playbook"] = "*play*.{yml,yaml}", + ["http://json.schemastore.org/chart"] = "Chart.{yml,yaml}", + ["https://json.schemastore.org/dependabot-v2"] = ".github/dependabot.{yml,yaml}", + ["https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"] = "*gitlab-ci*.{yml,yaml}", + ["https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"] = "*api*.{yml,yaml}", + ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "*docker-compose*.{yml,yaml}", + ["https://raw.githubusercontent.com/argoproj/argo-workflows/master/api/jsonschema/schema.json"] = "*flow*.{yml,yaml}", + } + } +}} +lspconfig["pylsp"].setup({ + capabilities = capabilities, + on_attach = on_attach, +}) +-- lspconfig["cmake-language-server"].setup { capabilities = capabilities, on_attach = on_attach} +-- lspconfig["vscode-css-language-server"].setup { capabilities = capabilities, on_attach = on_attach} diff --git a/modules/hm/vim.nix b/modules/hm/vim.nix index 0b78a41..f0fe5a0 100644 --- a/modules/hm/vim.nix +++ b/modules/hm/vim.nix @@ -2,131 +2,185 @@ let vp = pkgs.vimPlugins; in { programs.neovim = { enable = true; + + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + plugins = [ - # Git related plugins - vp.fugitive - vp.rhubarb + # # Git related plugins + # vp.fugitive + # vp.rhubarb - - # Detect tabstop and shiftwidth automatically - vp.sleuth - - - # LSP - { - plugin = vp.fidget-nvim; - config = '' - require("fidget").setup({}) - ''; - type = "lua"; - } - vp.neodev-nvim + # vp.lsp-zero-nvim + # vp.nvim-cmp + # vp.cmp-nvim-lsp # vp.nvim-lspconfig + + vp.telescope-fzf-native-nvim + { + plugin = vp.telescope-nvim; + type = "lua"; + config = '' + local telescope = require("telescope") + local actions = require("telescope.actions") + + telescope.setup({ + defaults = { + mappings = { + i = { + [""] = actions.move_selection_previous, -- move to prev result + [""] = actions.move_selection_next, -- move to next result + [""] = actions.send_selected_to_qflist + actions.open_qflist, + } + } + } + }) + + telescope.load_extension("fzf"); + + local keymap = vim.keymap + + keymap.set("n", "ff", "Telescope find_files", { desc = "Fuzzy find files in cwd" }) + keymap.set("n", "fr", "Telescope oldfiles", { desc = "Fuzzy find recent files" }) + keymap.set("n", "fs", "Telescope live_grep", { desc = "Find string in cwd" }) + keymap.set("n", "fc", "Telescope grep_string", { desc = "Fuzzy string under cursor in cwd" }) + ''; + } + + vp.dressing-nvim # Better UI for input and selection + + # Tree view + # vp.chadtree + vp.nerdtree-git-plugin + vp.vim-devicons + vp.nerdtree + + vp.cmp-buffer # source for text in buffer + vp.cmp-path # source for file system path + vp.luasnip + vp.cmp_luasnip + vp.friendly-snippets + { + plugin = vp.nvim-cmp; + type = "lua"; + config = builtins.readFile ./nvim/nvim-cmp-config.lua; + } + + # # Detect tabstop and shiftwidth automatically + # vp.sleuth + + # { + # plugin = vp.nvim-cmp; + # type = "lua"; + # config = '' + # require() + # ''; + # } + + # # LSP + vp.fidget-nvim # fidget moving while LSP is working + # vp.neodev-nvim + # # vp.nvim-lspconfig + vp.cmp-nvim-lsp { plugin = vp.nvim-lspconfig; type = "lua"; - config = '' - local lspconfig = require('lspconfig') - local capabilities = require("cmp_nvim_lsp").default_capabilities() - lspconfig.pylsp.setup {capabilities=capabilities} - lspconfig.nil_ls.setup {capabilities=capabilities} - lspconfig.rust_analyzer.setup {capabilities=capabilities} - lspconfig.texlab.setup {capabilities=capabilities} - ''; + config = builtins.readFile ./nvim/nvim-lspconfig.lua; } - # Autocompletion - ## Snippet engine & its associated nvim-cmp source - vp.luasnip - vp.cmp_luasnip - ## Adds LSP completion capabilities - vp.cmp-nvim-lsp - vp.cmp-path - ## Adds a number of user-friendly snippets - vp.friendly-snippets - ## NVIM CMP - vp.nvim-cmp + # # Autocompletion + # ## Snippet engine & its associated nvim-cmp source + # vp.luasnip + # vp.cmp_luasnip + # ## Adds LSP completion capabilities + # vp.cmp-nvim-lsp + # vp.cmp-path + # ## Adds a number of user-friendly snippets + # vp.friendly-snippets + # ## NVIM CMP + # vp.nvim-cmp - # Useful plugin to show you pending keybinds - { plugin = vp.which-key-nvim; config = ''require("which-key").setup({})''; type = "lua"; } + # # Useful plugin to show you pending keybinds + # { plugin = vp.which-key-nvim; config = ''require("which-key").setup({})''; type = "lua"; } # Adds git related signs to the gutter, as well as utilities for managing changes - { - plugin = vp.gitsigns-nvim; - config = '' - require("gitsigns").setup({ - -- See `:help gitsigns.txt` - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - on_attach = function(bufnr) - local gs = package.loaded.gitsigns + # { + # plugin = vp.gitsigns-nvim; + # config = '' + # require("gitsigns").setup({ + # -- See `:help gitsigns.txt` + # signs = { + # add = { text = '+' }, + # change = { text = '~' }, + # delete = { text = '_' }, + # topdelete = { text = '‾' }, + # changedelete = { text = '~' }, + # }, + # on_attach = function(bufnr) + # local gs = package.loaded.gitsigns - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end + # local function map(mode, l, r, opts) + # opts = opts or {} + # opts.buffer = bufnr + # vim.keymap.set(mode, l, r, opts) + # end - -- Navigation - map({ 'n', 'v' }, ']c', function() - if vim.wo.diff then - return ']c' - end - vim.schedule(function() - gs.next_hunk() - end) - return '' - end, { expr = true, desc = 'Jump to next hunk' }) + # -- Navigation + # map({ 'n', 'v' }, ']c', function() + # if vim.wo.diff then + # return ']c' + # end + # vim.schedule(function() + # gs.next_hunk() + # end) + # return '' + # end, { expr = true, desc = 'Jump to next hunk' }) - map({ 'n', 'v' }, '[c', function() - if vim.wo.diff then - return '[c' - end - vim.schedule(function() - gs.prev_hunk() - end) - return '' - end, { expr = true, desc = 'Jump to previous hunk' }) + # map({ 'n', 'v' }, '[c', function() + # if vim.wo.diff then + # return '[c' + # end + # vim.schedule(function() + # gs.prev_hunk() + # end) + # return '' + # end, { expr = true, desc = 'Jump to previous hunk' }) - -- Actions - -- visual mode - map('v', 'hs', function() - gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'stage git hunk' }) - map('v', 'hr', function() - gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } - end, { desc = 'reset git hunk' }) - -- normal mode - map('n', 'hs', gs.stage_hunk, { desc = 'git stage hunk' }) - map('n', 'hr', gs.reset_hunk, { desc = 'git reset hunk' }) - map('n', 'hS', gs.stage_buffer, { desc = 'git Stage buffer' }) - map('n', 'hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) - map('n', 'hR', gs.reset_buffer, { desc = 'git Reset buffer' }) - map('n', 'hp', gs.preview_hunk, { desc = 'preview git hunk' }) - map('n', 'hb', function() - gs.blame_line { full = false } - end, { desc = 'git blame line' }) - map('n', 'hd', gs.diffthis, { desc = 'git diff against index' }) - map('n', 'hD', function() - gs.diffthis '~' - end, { desc = 'git diff against last commit' }) + # -- Actions + # -- visual mode + # map('v', 'hs', function() + # gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } + # end, { desc = 'stage git hunk' }) + # map('v', 'hr', function() + # gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } + # end, { desc = 'reset git hunk' }) + # -- normal mode + # map('n', 'hs', gs.stage_hunk, { desc = 'git stage hunk' }) + # map('n', 'hr', gs.reset_hunk, { desc = 'git reset hunk' }) + # map('n', 'hS', gs.stage_buffer, { desc = 'git Stage buffer' }) + # map('n', 'hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) + # map('n', 'hR', gs.reset_buffer, { desc = 'git Reset buffer' }) + # map('n', 'hp', gs.preview_hunk, { desc = 'preview git hunk' }) + # map('n', 'hb', function() + # gs.blame_line { full = false } + # end, { desc = 'git blame line' }) + # map('n', 'hd', gs.diffthis, { desc = 'git diff against index' }) + # map('n', 'hD', function() + # gs.diffthis '~' + # end, { desc = 'git diff against last commit' }) - -- Toggles - map('n', 'tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' }) - map('n', 'td', gs.toggle_deleted, { desc = 'toggle git show deleted' }) + # -- Toggles + # map('n', 'tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' }) + # map('n', 'td', gs.toggle_deleted, { desc = 'toggle git show deleted' }) - -- Text object - map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', { desc = 'select git hunk' }) - end, - }) - ''; - type = "lua"; - } + # -- Text object + # map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', { desc = 'select git hunk' }) + # end, + # }) + # ''; + # type = "lua"; + # } # Cool color scheme { @@ -150,39 +204,42 @@ let vp = pkgs.vimPlugins; in { type = "lua"; } - # Add indentation guides even on blank lines - { - # See `:help ibl` - plugin = vp.indent-blankline-nvim; - config = '' - require("ibl").setup({}) - ''; - type = "lua"; - } + # # Add indentation guides even on blank lines + # { + # # See `:help ibl` + # plugin = vp.indent-blankline-nvim; + # config = '' + # require("ibl").setup({}) + # ''; + # type = "lua"; + # } - # "gc" to comment visual regions/lines - { - plugin = vp.comment-nvim; - config = '' - require("Comment").setup({}) - ''; - type = "lua"; - } + # # "gc" to comment visual regions/lines + # { + # plugin = vp.comment-nvim; + # config = '' + # require("Comment").setup({}) + # ''; + # type = "lua"; + # } - vp.plenary-nvim - vp.telescope-fzf-native-nvim - vp.telescope-nvim + # vp.plenary-nvim + # vp.telescope-fzf-native-nvim + # vp.telescope-nvim - vp.nvim-treesitter-textobjects - vp.nvim-treesitter + # vp.nvim-treesitter-textobjects + # vp.nvim-treesitter ]; # settings = { ignorecase = true; }; # coc.enable = true; - viAlias = true; - vimAlias = true; - vimdiffAlias = true; extraConfig = '' set mouse=a + set encoding=UTF-8 + set guifont=FiraCode\ Nerd\ Font\ Mono\ 10 + let g:airline_powerline_fonts = 1 + ''; + extraLuaConfig = '' + vim.g.mapleader = " " ''; }; }