nvim: enable inlay hints + toggling

This commit is contained in:
Daniel Lundin 2024-12-02 09:42:24 +01:00
parent 5c319ac288
commit aed9af6f45
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI
6 changed files with 110 additions and 31 deletions

View file

@ -40,11 +40,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1730504689, "lastModified": 1733269028,
"narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=", "narHash": "sha256-kVq/jAKKtbvWwbL9wf0SKDxtxsC5Gb+nlIYEFnyXhGA=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "506278e768c2a08bec68eb62932193e341f55c90", "rev": "e37654df08605b510ad84eceaafcc7248495e843",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -103,11 +103,11 @@
"zig": "zig" "zig": "zig"
}, },
"locked": { "locked": {
"lastModified": 1732920523, "lastModified": 1733235265,
"narHash": "sha256-/Udch6RRLBSjluDXjQHWpiYFFJR15g+qV263ibVBwoc=", "narHash": "sha256-BZBmyv2gY4SmanxCM0ZVYhYx7t2/Az/okDOQj+4RIso=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "3c637a2777885dab9f8bb9d2b7c36411d62e1e4c", "rev": "50dc4b75d73bab7631e22e19e940331ad7ac8cfd",
"revCount": 8136, "revCount": 8155,
"type": "git", "type": "git",
"url": "ssh://git@github.com/ghostty-org/ghostty" "url": "ssh://git@github.com/ghostty-org/ghostty"
}, },
@ -209,11 +209,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1732884235, "lastModified": 1733317578,
"narHash": "sha256-r8j6R3nrvwbT1aUp4EPQ1KC7gm0pu9VcV1aNaB+XG6Q=", "narHash": "sha256-anN/LcP5IuqEARvhPETg1vnbyG3IQ0wdvSAYEJfIQzA=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "819f682269f4e002884702b87e445c82840c68f2", "rev": "ad48eb25cd0b00ce730da00fa1f8e6e6c27b397d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -232,11 +232,11 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1732925246, "lastModified": 1733314815,
"narHash": "sha256-MjqyzOEa6s9OGO8SMh5C2kqo57+iSNsgDbzPBbpi4QU=", "narHash": "sha256-FxQzRALeGEfZg7ZA+ArlGBbs3Jtwd7Tr7+E6iucHKDA=",
"owner": "nix-community", "owner": "nix-community",
"repo": "neovim-nightly-overlay", "repo": "neovim-nightly-overlay",
"rev": "7461a0b228bb48bb02af086f8b9ee9a83583120b", "rev": "7545e949aa9bc2396130191100f1fbf9765bc448",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -248,11 +248,11 @@
"neovim-src": { "neovim-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1732903628, "lastModified": 1733247868,
"narHash": "sha256-JF8zmoLdqmbKCSS5Smf/Yj0jEl5f+qKhSubhPo/BvUM=", "narHash": "sha256-TGXXXV/jWUBF2ZBiYt6RKIvUGpsefDe/RSXnUzejxMU=",
"owner": "neovim", "owner": "neovim",
"repo": "neovim", "repo": "neovim",
"rev": "2833925cfc688786759d6a980a1ad62b62d20570", "rev": "ae93c7f369a174f3d738ab55030de2c9dfc10c57",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -263,11 +263,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1732617236, "lastModified": 1733097829,
"narHash": "sha256-PYkz6U0bSEaEB1al7O1XsqVNeSNS+s3NVclJw7YC43w=", "narHash": "sha256-9hbb1rqGelllb4kVUCZ307G2k3/UhmA8PPGBoyuWaSw=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "af51545ec9a44eadf3fe3547610a5cdd882bc34e", "rev": "2c15aa59df0017ca140d9ba302412298ab4bf22a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -279,11 +279,11 @@
}, },
"nixpkgs-stable": { "nixpkgs-stable": {
"locked": { "locked": {
"lastModified": 1732749044, "lastModified": 1733220138,
"narHash": "sha256-T38FQOg0BV5M8FN1712fovzNakSOENEYs+CSkg31C9Y=", "narHash": "sha256-Yh5XZ9yVurrcYdNTSWxYgW4+EJ0pcOqgM1043z9JaRc=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "0c5b4ecbed5b155b705336aa96d878e55acd8685", "rev": "bcb68885668cccec12276bbb379f8f2557aa06ce",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -295,11 +295,11 @@
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1732937961, "lastModified": 1733097829,
"narHash": "sha256-B5pYT+IVaqcrfOekkwKvx/iToDnuQWzc2oyDxzzBDc4=", "narHash": "sha256-9hbb1rqGelllb4kVUCZ307G2k3/UhmA8PPGBoyuWaSw=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "4703b8d2c708e13a8cab03d865f90973536dcdf5", "rev": "2c15aa59df0017ca140d9ba302412298ab4bf22a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -311,11 +311,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1732837521, "lastModified": 1733212471,
"narHash": "sha256-jNRNr49UiuIwaarqijgdTR2qLPifxsVhlJrKzQ8XUIE=", "narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "970e93b9f82e2a0f3675757eb0bfc73297cc6370", "rev": "55d15ad12a74eb7d4646254e13638ad0c4128776",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -50,7 +50,6 @@
plugins = with pkgs.vimPlugins; [ plugins = with pkgs.vimPlugins; [
friendly-snippets friendly-snippets
go-nvim go-nvim
rustaceanvim
targets-vim targets-vim
ts-comments-nvim ts-comments-nvim
@ -116,6 +115,23 @@
''; '';
} }
{
plugin = pkgs.vimUtils.buildVimPlugin {
name = "inlay-hints";
src = pkgs.fetchFromGitHub {
owner = "MysticalDevil";
repo = "inlay-hints.nvim";
rev = "af84dee42cd118af6d592b06c1c0e45d6432a6c0"; # 2024-08-23
hash = "sha256-DZVtFAUK9c8GInp+JdCQ1BKe0dkAheHKI67oxdMmA24=";
};
};
type = "lua";
config = ''
require('inlay-hints').setup()
require("inlay-hints.utils").enable_inlay_hints()
'';
}
{ {
plugin = codeium-nvim; plugin = codeium-nvim;
type = "lua"; type = "lua";
@ -185,6 +201,12 @@
type = "lua"; type = "lua";
config = lib.fileContents ./mini.lua; config = lib.fileContents ./mini.lua;
} }
{
plugin = rustaceanvim;
type = "lua";
config = lib.fileContents ./rust.lua;
}
]; ];
}; };
} }

View file

@ -152,5 +152,5 @@ vim.keymap.set("n", "K", function()
vim.keymap.set("n", "<Leader>ub", function() vim.keymap.set("n", "<Leader>ub", function()
vim.o.background = (vim.o.background == "light" and "dark" or "light") vim.o.background = (vim.o.background == "light" and "dark" or "light")
end, opts("Toggle dark/light background")) end, opts("Toggle dark/light background"))
vim.keymap.set("n", "<Leader>uh", "<cmd>InlayHintsToggle<cr>", opts("Toggle inlay hints"))

View file

@ -1,12 +1,27 @@
local lspconfig = require("lspconfig") local lspconfig = require("lspconfig")
local servers = { local servers = {
cssls = {}, cssls = {},
gopls = {},
html = {}, html = {},
jsonls = {}, jsonls = {},
superhtml = {}, superhtml = {},
ts_ls = {}, ts_ls = {},
gopls = {
settings = {
gopls = {
hints = {
rangeVariableTypes = true,
parameterNames = true,
constantValues = true,
assignVariableTypes = true,
compositeLiteralFields = true,
compositeLiteralTypes = true,
functionTypeParameters = true,
},
},
},
},
harper_ls = { harper_ls = {
filetypes = { filetypes = {
"asciidoc", "c", "gitcommit", "go", "html", "javascript", "just", "lua", "markdown", "asciidoc", "c", "gitcommit", "go", "html", "javascript", "just", "lua", "markdown",
@ -22,6 +37,7 @@ local servers = {
path = vim.split(package.path, ";"), path = vim.split(package.path, ";"),
}, },
diagnostics = { globals = { "vim", "hs" } }, diagnostics = { globals = { "vim", "hs" } },
hint = { enable = true },
workspace = { workspace = {
library = { library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true, [vim.fn.expand("$VIMRUNTIME/lua")] = true,

40
home/common/nvim/rust.lua Normal file
View file

@ -0,0 +1,40 @@
vim.g.rustaceanvim = {
server = {
settings = {
["rust-analyzer"] = {
inlayHints = {
bindingModeHints = {
enable = false,
},
chainingHints = {
enable = true,
},
closingBraceHints = {
enable = true,
minLines = 25,
},
closureReturnTypeHints = {
enable = "never",
},
lifetimeElisionHints = {
enable = "never",
useParameterNames = false,
},
maxLength = 25,
parameterHints = {
enable = true,
},
reborrowHints = {
enable = "never",
},
renderColons = true,
typeHints = {
enable = true,
hideClosureInitialization = false,
hideNamedConstructor = false,
},
},
},
},
},
}

View file

@ -13,6 +13,7 @@
plugins = with pkgs.vimPlugins; [ plugins = with pkgs.vimPlugins; [
ts-comments-nvim ts-comments-nvim
nvim-ts-context-commentstring nvim-ts-context-commentstring
playground
{ {
plugin = nvim-treesitter-context; plugin = nvim-treesitter-context;