Skip to content

Commit

Permalink
feat: deprecate lsp-inlayhints-nvim in favor of built-ins
Browse files Browse the repository at this point in the history
  • Loading branch information
konradmalik committed Sep 22, 2023
1 parent f77efaa commit b4f21e6
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 63 deletions.
42 changes: 20 additions & 22 deletions config/native/lua/konrad/lsp/capability_handlers/inlayhints.lua
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
local inlayhints_is_enabled = true;
local inlayhints_is_enabled = true

local M = {}

---@param data table
---@return table of commands and buf_commands for this client
M.attach = function(data)
local bufnr = data.bufnr
local client = data.client

vim.cmd('packadd lsp-inlayhints.nvim')
local inlayhints = require('lsp-inlayhints')
inlayhints.setup({ enabled_at_startup = inlayhints_is_enabled })
inlayhints.on_attach(client, bufnr)

vim.api.nvim_create_user_command("InlayHintsToggle",
function()
inlayhints_is_enabled = not inlayhints_is_enabled
inlayhints.toggle()
vim.api.nvim_create_autocmd({ "InsertEnter" }, {
callback = function()
if inlayhints_is_enabled then
vim.lsp.inlay_hint(bufnr, true)
end
end,
})
vim.api.nvim_create_autocmd({ "InsertLeave" }, {
callback = function()
if inlayhints_is_enabled then
inlayhints.show()
else
inlayhints.reset()
vim.lsp.inlay_hint(bufnr, false)
end
print('Setting inlayhints to: ' .. tostring(inlayhints_is_enabled))
end, {
desc = "Enable/disable inlayhints with lsp",
})
end,
})

vim.api.nvim_create_user_command("InlayHintsToggle", function()
inlayhints_is_enabled = not inlayhints_is_enabled
print("Setting inlayhints to: " .. tostring(inlayhints_is_enabled))
end, {
desc = "Enable/disable inlayhints with lsp",
})

return {
commands = { "InlayHintsToggle" },
}
end

M.detach = function()
require('lsp-inlayhints').reset()
end

return M
10 changes: 1 addition & 9 deletions config/native/lua/konrad/lsp/event_handlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ M.detach = function(client, bufnr)
require("konrad.lsp.capability_handlers.codelens").detach()
end

-- TODO not sure why this always returns true
-- if client.supports_method("textDocument/inlayHint") then
if client.server_capabilities.inlayHintProvider then
require("konrad.lsp.capability_handlers.inlayhints").detach()
end

registry.deregister(client, bufnr)

local clients = vim.lsp.get_active_clients({ bufnr = bufnr })
Expand Down Expand Up @@ -121,9 +115,7 @@ M.attach = function(client, bufnr)
)
end

-- TODO not sure why this always returns true
-- if client.supports_method("textDocument/inlayHint") then
if client.server_capabilities.inlayHintProvider then
if client.supports_method("textDocument/inlayHint") then
registry.register_once("InlayHints", register_data, require("konrad.lsp.capability_handlers.inlayhints").attach)
end

Expand Down
18 changes: 9 additions & 9 deletions config/native/plugin/gitsigns.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
local gitsigns = require("gitsigns")
gitsigns.setup({
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '-' },
topdelete = { text = '' },
changedelete = { text = '~' },
add = { text = "+" },
change = { text = "~" },
delete = { text = "-" },
topdelete = { text = "" },
changedelete = { text = "~" },
},
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
})

Expand Down
17 changes: 0 additions & 17 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
heirline-nvim = { url = "github:rebelot/heirline.nvim"; flake = false; };
indent-blankline-nvim = { url = "github:lukas-reineke/indent-blankline.nvim"; flake = false; };
kanagawa-nvim = { url = "github:rebelot/kanagawa.nvim"; flake = false; };
lsp-inlayhints-nvim = { url = "github:lvimuser/lsp-inlayhints.nvim"; flake = false; };
luasnip = { url = "github:L3MON4D3/LuaSnip"; flake = false; };
neo-tree-nvim = { url = "github:nvim-neo-tree/neo-tree.nvim"; flake = false; };
neodev-nvim = { url = "github:folke/neodev.nvim"; flake = false; };
Expand Down
4 changes: 0 additions & 4 deletions packages/neovim-pde/plugins.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ processMadePlugins (with pkgs.neovimPlugins;[
fidget-nvim
plenary-nvim
{ plugin = SchemaStore-nvim; optional = true; }
{
plugin = lsp-inlayhints-nvim;
optional = true;
}
{
plugin = omnisharp-extended-lsp-nvim;
optional = true;
Expand Down
1 change: 0 additions & 1 deletion packages/plugins/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ rec {
heirline-nvim = buildVim "heirline.nvim" inputs.heirline-nvim;
indent-blankline-nvim = buildVim "indent-blankline.nvim" inputs.indent-blankline-nvim;
kanagawa-nvim = buildVim "kanagawa.nvim" inputs.kanagawa-nvim;
lsp-inlayhints-nvim = buildVim "lsp-inlayhints.nvim" inputs.lsp-inlayhints-nvim;
luasnip = buildVim "luasnip" inputs.luasnip;
neo-tree-nvim = (buildVim "neo-tree.nvim" inputs.neo-tree-nvim).overrideAttrs {
dependencies = [ plenary-nvim nui-nvim ];
Expand Down

0 comments on commit b4f21e6

Please sign in to comment.