From e5e206a0c01068748a639734e6703e0dbe89686f Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Wed, 10 Jul 2024 00:45:24 +0200 Subject: [PATCH] nvim: use hover.nvim --- flake.lock | 50 +++++++++++++++--------------- home/config/nvim/nifoc/keymap.fnl | 8 +++-- home/config/nvim/plugins/hover.fnl | 8 +++++ home/config/nvim/plugins/lsp.fnl | 36 +-------------------- home/programs/nvim/default.nix | 6 ++++ home/programs/nvim/plugins.nix | 25 ++++++++++----- home/programs/nvim/plugins.yaml | 1 + 7 files changed, 64 insertions(+), 70 deletions(-) create mode 100644 home/config/nvim/plugins/hover.fnl diff --git a/flake.lock b/flake.lock index e3ee6c1..a83d246 100644 --- a/flake.lock +++ b/flake.lock @@ -14,11 +14,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1718371084, - "narHash": "sha256-abpBi61mg0g+lFFU0zY4C6oP6fBwPzbHPKBGw676xsA=", + "lastModified": 1720546205, + "narHash": "sha256-boCXsjYVxDviyzoEyAk624600f3ZBo/DKtUdvMTpbGY=", "owner": "ryantm", "repo": "agenix", - "rev": "3a56735779db467538fb2e577eda28a9daacaca6", + "rev": "de96bd907d5fbc3b14fc33ad37d1b9a3cb15edc6", "type": "github" }, "original": { @@ -38,11 +38,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1717279440, - "narHash": "sha256-kH04ReTjxOpQumgWnqy40vvQLSnLGxWP6RF3nq5Esrk=", + "lastModified": 1720542474, + "narHash": "sha256-aKjJ/4l2I9+wNGTaOGRsuS3M1+IoTibqgEMPDikXm04=", "owner": "zhaofengli", "repo": "attic", - "rev": "717cc95983cdc357bc347d70be20ced21f935843", + "rev": "6139576a3ce6bb992e0f6c3022528ec233e45f00", "type": "github" }, "original": { @@ -492,11 +492,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1720429258, - "narHash": "sha256-d6JI5IgJ1xdrk7DvYVx7y8ijcYz5I1nhCwOiDP6cq00=", + "lastModified": 1720515935, + "narHash": "sha256-8b+fzR4W2hI5axwB+4nBwoA15awPKkck4ghhCt8v39M=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "72d3c007024ce47d838bb38693c8773812f54bf2", + "rev": "a111ce6b537df12a39874aa9672caa87f8677eda", "type": "github" }, "original": { @@ -508,11 +508,11 @@ }, "nixos-unstable": { "locked": { - "lastModified": 1720459846, - "narHash": "sha256-3gf8pkyp/yjFdLJo7PSQ/Vmta9QBPWfKs5SFc/wh3h4=", + "lastModified": 1720501375, + "narHash": "sha256-+uhyVoqSWA3+dQAeeWwovRmoD9eeqCWaAnpOuuqalNk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c030874db3ce4ff192aabf059988ed1be95d167a", + "rev": "bb1588c3045cfdc18154cb45a2f2186122cbbad8", "type": "github" }, "original": { @@ -524,11 +524,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1720368505, - "narHash": "sha256-5r0pInVo5d6Enti0YwUSQK4TebITypB42bWy5su3MrQ=", + "lastModified": 1720498663, + "narHash": "sha256-juqJkkdAt44mOfA43q1qUHn7iWoK++81lR8Mh7N/EF8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ab82a9612aa45284d4adf69ee81871a389669a9e", + "rev": "106e145e1d4583d1e2bb20e54947d15ad55e75e1", "type": "github" }, "original": { @@ -568,16 +568,16 @@ }, "nixpkgs-stable_2": { "locked": { - "lastModified": 1718811006, - "narHash": "sha256-0Y8IrGhRmBmT7HHXlxxepg2t8j1X90++qRN3lukGaIk=", + "lastModified": 1720386169, + "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "03d771e513ce90147b65fe922d87d3a0356fc125", + "rev": "194846768975b7ad2c4988bdb82572c00222c0d7", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.11", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } @@ -617,11 +617,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1720450253, - "narHash": "sha256-1in42htN3g3MnE3/AO5Qgs6pMWUzmtPQ7s675brO8uw=", + "lastModified": 1720524665, + "narHash": "sha256-ni/87oHPZm6Gv0ECYxr1f6uxB0UKBWJ6HvS7lwLU6oY=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "2b6bd3c87d3a66fb0b8f2f06c985995e04b4fb96", + "rev": "8d6a17d0cdf411c55f12602624df6368ad86fac1", "type": "github" }, "original": { @@ -738,11 +738,11 @@ ] }, "locked": { - "lastModified": 1720436211, - "narHash": "sha256-/cKXod0oGLl+vH4bKBZnTV3qxrw4jgOLnyQ8KXey5J8=", + "lastModified": 1720507012, + "narHash": "sha256-QIeZ43t9IVB4dLsFaWh2f4C7JSRfK7p+Y1U9dULsLXU=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "6fc8bded78715cdd43a3278a14ded226eb3a239e", + "rev": "8b63fe8cf7892c59b3df27cbcab4d5644035d72f", "type": "github" }, "original": { diff --git a/home/config/nvim/nifoc/keymap.fnl b/home/config/nvim/nifoc/keymap.fnl index c463ea0..702b3fa 100644 --- a/home/config/nvim/nifoc/keymap.fnl +++ b/home/config/nvim/nifoc/keymap.fnl @@ -7,6 +7,7 @@ telescope-ivy (telescope-themes.get_ivy) telescope-dropdown (telescope-themes.get_dropdown) npairs (require :nvim-autopairs) + hover (require :hover) gitsigns (require :gitsigns) neogit (require :neogit) wk (require :which-key) @@ -89,6 +90,9 @@ (keymap.set :n :y "(YankyYank)") (keymap.set :x :y "(YankyYank)") (keymap.set :n "-" :Oil {:desc "Open Oil"}) + ;; hover.nvim + (keymap.set :n :K hover.hover {:desc "Show Documentation"}) + (keymap.set :n :gK hover.hover_select {:desc "hover.nvim selection"}) ;; Label (wk.register {:v {:name :+vcs} :l {:name :+list/lsp} @@ -116,9 +120,7 @@ {:buffer bufnr :desc "Find Definitions"}) (keymap.set :n :lfi #(telescope-builtin.lsp_implementations telescope-dropdown) - {:buffer bufnr :desc "Find Implementations"}) - (keymap.set :n :K vim.lsp.buf.hover - {:buffer bufnr :desc "Show Documentation"})) + {:buffer bufnr :desc "Find Implementations"})) (fn mod.terminal-open [bufnr] (let [map-opts {:buffer bufnr}] diff --git a/home/config/nvim/plugins/hover.fnl b/home/config/nvim/plugins/hover.fnl new file mode 100644 index 0000000..5d9d3a7 --- /dev/null +++ b/home/config/nvim/plugins/hover.fnl @@ -0,0 +1,8 @@ +(let [hover (require :hover)] + (hover.setup {:init #(do + (require :hover.providers.lsp) + (require :hover.providers.diagnostic)) + :preview_opts {:border :single} + :preview_window false + :title true + :mouse_providers []})) diff --git a/home/config/nvim/plugins/lsp.fnl b/home/config/nvim/plugins/lsp.fnl index da7aa21..39a8a1a 100644 --- a/home/config/nvim/plugins/lsp.fnl +++ b/home/config/nvim/plugins/lsp.fnl @@ -100,38 +100,4 @@ (lsp.yamlls.setup (->> {:settings {:yaml {:schemaStore {:enable false :url ""} :schemas (schemastore.yaml.schemas)}}} - (vim.tbl_extend :force default-config)))) - ;; Hacks - - (fn add-inline-highlights [bufnr] - (let [lines (vim.api.nvim_buf_get_lines bufnr 0 -1 false) - mapping {"@%S+" "@parameter" - "^%s*(Parameters:)" "@text.title" - "^%s*(Return:)" "@text.title" - "^%s*(See also:)" "@text.title" - "{%S-}" "@parameter" - "|%S-|" "@text.reference"}] - (each [l line (ipairs lines)] - (each [pattern hl_group (pairs mapping)] - (var from 1) - (while from - (var to nil) - (set (from to) (line:find pattern from)) - (when from - (vim.api.nvim_buf_set_extmark bufnr ns (- l 1) (- from 1) - {:end_col to : hl_group})) - (set from (if to (+ to 1) nil))))))) - - ;; https://github.com/MariaSolOs/dotfiles/blob/b4516aa30c2912011a7b9c9857f01dee1ba5b57f/.config/nvim/lua/lsp.lua#L260C1-L260C1 - (set vim.lsp.util.stylize_markdown - (fn [bufnr raw-contents opts] - (var contents raw-contents) - (set contents - (vim.lsp.util._normalize_markdown contents - {:width (vim.lsp.util._make_floating_popup_size contents - opts)})) - (tset vim :bo bufnr :filetype :markdown) - (vim.treesitter.start bufnr) - (vim.api.nvim_buf_set_lines bufnr 0 -1 false contents) - (add-inline-highlights bufnr) - contents))) + (vim.tbl_extend :force default-config))))) diff --git a/home/programs/nvim/default.nix b/home/programs/nvim/default.nix index 8dcdd68..9995df6 100644 --- a/home/programs/nvim/default.nix +++ b/home/programs/nvim/default.nix @@ -270,6 +270,12 @@ in type = "fennel"; } + { + plugin = hover-nvim; + config = builtins.readFile ../../config/nvim/plugins/hover.fnl; + type = "fennel"; + } + { plugin = gitsigns-nvim; config = builtins.readFile ../../config/nvim/plugins/gitsigns.fnl; diff --git a/home/programs/nvim/plugins.nix b/home/programs/nvim/plugins.nix index 927584c..d635de8 100644 --- a/home/programs/nvim/plugins.nix +++ b/home/programs/nvim/plugins.nix @@ -40,7 +40,7 @@ in }; wezterm-nvim = buildVimPlugin { pname = "wezterm.nvim"; - version = "2024-06-01"; + version = "2024-06-02"; src = fetchFromGitHub { owner = "willothy"; repo = "wezterm.nvim"; @@ -121,8 +121,8 @@ in src = fetchFromGitHub { owner = "nvim-treesitter"; repo = "nvim-treesitter"; - rev = "53c79ddc28b0df3263d629f5e20c9283b05841ca"; - sha256 = "110m9gpgzdqk5lgfcsybgxzka82lxjmkymdgwa1m5fw80hm6y6a9"; + rev = "c1ad655b6a0c83ab48e55240f367e2bc0c15af31"; + sha256 = "0qcl97gzxc0i0nz988nwhfjcphvajsmf50jdnd5glqf0ai1ghbpy"; fetchSubmodules = false; }; }; @@ -414,7 +414,7 @@ in }; oil-nvim = buildVimPlugin { pname = "oil.nvim"; - version = "2024-07-06"; + version = "2024-07-07"; src = fetchFromGitHub { owner = "stevearc"; repo = "oil.nvim"; @@ -467,14 +467,25 @@ in fetchSubmodules = false; }; }; + hover-nvim = buildVimPlugin { + pname = "hover.nvim"; + version = "2024-06-12"; + src = fetchFromGitHub { + owner = "lewis6991"; + repo = "hover.nvim"; + rev = "4339cbbcb572b1934c53dcb66ad4bf6a0abb7918"; + sha256 = "1nnhm8xhkdjvqal7016v22cljhpga8y0mydmvalz954cviskhna3"; + fetchSubmodules = false; + }; + }; gitsigns-nvim = buildVimPlugin { pname = "gitsigns.nvim"; - version = "2024-07-07"; + version = "2024-07-09"; src = fetchFromGitHub { owner = "lewis6991"; repo = "gitsigns.nvim"; - rev = "220446c8c86a280180d852efac60991eaf1a21d4"; - sha256 = "0mrslcm75mnds7jklhd7rn4h02sa8ifbqw04qahb7mqgylrzg07i"; + rev = "375c44bdfdde25585466a966f00c2e291db74f2d"; + sha256 = "18vi0ms8gz17vz6rq0pil7rybpjp6nx4jmf2ywhnh1xy08yn5zim"; fetchSubmodules = false; }; }; diff --git a/home/programs/nvim/plugins.yaml b/home/programs/nvim/plugins.yaml index bbadb27..8e5c611 100644 --- a/home/programs/nvim/plugins.yaml +++ b/home/programs/nvim/plugins.yaml @@ -54,6 +54,7 @@ - src: lukas-reineke/indent-blankline.nvim - src: lukas-reineke/virt-column.nvim - src: axieax/urlview.nvim +- src: lewis6991/hover.nvim - src: lewis6991/gitsigns.nvim - src: sindrets/diffview.nvim - src: NeogitOrg/neogit