From 01df75e5f51a5604e2a3939fd7da6892c1be6ba0 Mon Sep 17 00:00:00 2001 From: loctvl842 Date: Thu, 25 May 2023 14:46:41 +0700 Subject: [PATCH] feat(lsp): support `rust_analyzer` and add `inlay_hint` --- lazy-lock.json | 27 +++++++++++----------- lua/tvl/config/lsp/servers.lua | 7 ++++++ lua/tvl/core/resources/lsp.lua | 5 ++++ lua/tvl/core/resources/settings.lua | 1 - lua/tvl/core/resources/ui.lua | 26 ++++++++++++--------- lua/tvl/util.lua | 36 ----------------------------- 6 files changed, 41 insertions(+), 61 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 2cf7f6c..c8a7157 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -13,35 +13,36 @@ "dashboard-nvim": { "branch": "master", "commit": "0af0ad181db271ef8d5a332f4cfcec9118340497" }, "dressing.nvim": { "branch": "master", "commit": "2f17eee4d7709dacfad2a28f35e2acfe9a6cb09d" }, "emmet-vim": { "branch": "master", "commit": "def5d57a1ae5afb1b96ebe83c4652d1c03640f4d" }, - "friendly-snippets": { "branch": "main", "commit": "1d0dac346de7c6895ac72528df3276386c6b149b" }, + "friendly-snippets": { "branch": "main", "commit": "ef6547d2f586e08e071efeebac835e545f3015cc" }, "gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" }, "indent-blankline.nvim": { "branch": "master", "commit": "86d1b71c5c26168c3a3a9ff5f69e833889a09c1d" }, "lazy.nvim": { "branch": "main", "commit": "761b8388af5bcb451e30d886163fcd129278e1d1" }, + "lsp-inlayhints.nvim": { "branch": "main", "commit": "62c7b8dd8ac9933b071912fe3c789ef2cb704672" }, "lsp_signature.nvim": { "branch": "master", "commit": "4665921ff8e30601c7c1328625b3abc1427a6143" }, "lspsaga.nvim": { "branch": "main", "commit": "e39c210c5f19a01a627e1d25544e5aca52efb522" }, "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "90a8bbf106b85b76951a34c542058ffa807de2b1" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "c55d18f3947562e699d34d89681edbf9f0e250d3" }, "mason-null-ls.nvim": { "branch": "main", "commit": "cfbd83909cbc56e2f07cb3f8a03157e069c5c91c" }, - "mason.nvim": { "branch": "main", "commit": "253961cfe9b0a63b2524088be294acd7522366e5" }, + "mason.nvim": { "branch": "main", "commit": "08b2fd308e0107eab9f0b59d570b69089fd0b522" }, "middleclass": { "branch": "master", "commit": "9fab4d5bca67262614960960ca35c4740eb2be2c" }, "mini.comment": { "branch": "main", "commit": "9ead47cef4266efa5145808b838762c658b74f74" }, "mini.indentscope": { "branch": "main", "commit": "f60e9b51a6214c73a170ffc5445ce91560981031" }, "mini.pairs": { "branch": "main", "commit": "771c08bd313614c7e9a1904d277ac76eb226f674" }, - "monokai-pro.nvim": { "branch": "master", "commit": "e7b38bdb95fc144456703bb0ff5692c68093cc8e" }, + "monokai-pro.nvim": { "branch": "master", "commit": "0fa4844cdabf92ff5719994e0410178ffc0be077" }, "neo-tree.nvim": { "branch": "v2.x", "commit": "abad8863cb280e64663b8b67755c47c233958946" }, - "noice.nvim": { "branch": "main", "commit": "ab39f4f6507df44b41ff3077086d7bfd79bfad6e" }, + "noice.nvim": { "branch": "main", "commit": "cf82630ee5297b54e8e98f9ee2376c16b239af7c" }, "nui.nvim": { "branch": "main", "commit": "698e75814cd7c56b0dd8af4936bcef2d13807f3c" }, - "null-ls.nvim": { "branch": "main", "commit": "08bb00c7c2cd58c72e02cf54e4b9cbfe14b03e09" }, - "nvim": { "branch": "main", "commit": "73587f9c454da81679202f1668c30fea6cdafd5e" }, - "nvim-cmp": { "branch": "main", "commit": "d153771162bd9795d9f7142df5c674b61066a585" }, + "null-ls.nvim": { "branch": "main", "commit": "77e53bc3bac34cc273be8ed9eb9ab78bcf67fa48" }, + "nvim": { "branch": "main", "commit": "8338b02e9a8ffcb999520de7f15943712618760f" }, + "nvim-cmp": { "branch": "main", "commit": "3ac8d6cd29c74ff482d8ea47d45e5081bfc3f5ad" }, "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, "nvim-jdtls": { "branch": "master", "commit": "a5c6f38f8151d7b4f5b32c005a95022fa66f4c9d" }, "nvim-lightbulb": { "branch": "master", "commit": "ca5b44a8efffb5fec1963ccd21f25ec04cc778b7" }, - "nvim-lspconfig": { "branch": "master", "commit": "df58d91c9351a9dc5be6cf8d54f49ab0d9a64e73" }, + "nvim-lspconfig": { "branch": "master", "commit": "570aae82f8c6bc15fb6e559ed7d5a3fd85374329" }, "nvim-navic": { "branch": "master", "commit": "15704c607569d6c5cfeab486d3ef9459645a70ce" }, "nvim-notify": { "branch": "master", "commit": "bdd647f61a05c9b8a57c83b78341a0690e9c29d7" }, "nvim-scrollbar": { "branch": "main", "commit": "35f99d559041c7c0eff3a41f9093581ceea534e8" }, - "nvim-treesitter": { "branch": "master", "commit": "a67a4ab6423d28d075e6054e9d0c5cef80b5acab" }, + "nvim-treesitter": { "branch": "master", "commit": "9bef7260449b4ed5e917eda87b6eca6853526329" }, "nvim-ts-autotag": { "branch": "main", "commit": "40615e96075c743ef47aaf9de966dc348bec6459" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "0bf8fbc2ca8f8cdb6efbd0a9e32740d7a991e4c3" }, "nvim-ts-rainbow2": { "branch": "master", "commit": "cee4601ff8aac73dee4afa1074814343bb5a0b80" }, @@ -53,13 +54,13 @@ "promise-async": { "branch": "main", "commit": "38a4575da9497326badd3995e768b4ccf0bb153e" }, "rnvimr": { "branch": "main", "commit": "4f4fbd29e2e0869bea9a8376e06fca4331de60c9" }, "statuscol.nvim": { "branch": "main", "commit": "7ee8d982331019fec3a90ec87b98d6b4405cacbe" }, - "telescope.nvim": { "branch": "master", "commit": "d77b37f4520e5fc2cf4c74c12e42ed4b589bd367" }, + "telescope.nvim": { "branch": "master", "commit": "ff8ed2351fac3bfaf99ee6f870b4e9055258a803" }, "toggleterm.nvim": { "branch": "main", "commit": "026dff5e2b504941cf172691561a67ea362596aa" }, - "tokyonight.nvim": { "branch": "main", "commit": "df13e3268a44f142999fa166572fe95a650a0b37" }, + "tokyonight.nvim": { "branch": "main", "commit": "d0baf68fa42d41994018b54f67fb42de942e0228" }, "vim-bbye": { "branch": "master", "commit": "903f5eb17f72ebf7b0b1524bbb792c0b36761af6" }, "vim-illuminate": { "branch": "master", "commit": "a2907275a6899c570d16e95b9db5fd921c167502" }, "vim-startuptime": { "branch": "master", "commit": "daacd02e773944b8de312ddac83f436fae92cbb9" }, "vim-visual-multi": { "branch": "master", "commit": "1c9207b28c8898ab01b54e6d6b61b0b820a814bc" }, - "which-key.nvim": { "branch": "main", "commit": "912ef1a9b018bbe45df1529345e42ae0ac896d63" }, + "which-key.nvim": { "branch": "main", "commit": "e271c28118998c93a14d189af3395812a1aa646c" }, "windows.nvim": { "branch": "main", "commit": "c7492552b23d0ab30325e90b56066ec51242adc8" } } \ No newline at end of file diff --git a/lua/tvl/config/lsp/servers.lua b/lua/tvl/config/lsp/servers.lua index 26b3793..2ae774e 100755 --- a/lua/tvl/config/lsp/servers.lua +++ b/lua/tvl/config/lsp/servers.lua @@ -1,4 +1,11 @@ local servers = { + rust_analyzer = { + settings = { + ["rust-analyzer"] = { + inlayHints = true, + }, + }, + }, clangd = {}, cssls = {}, html = {}, diff --git a/lua/tvl/core/resources/lsp.lua b/lua/tvl/core/resources/lsp.lua index 9cf1abe..1857710 100755 --- a/lua/tvl/core/resources/lsp.lua +++ b/lua/tvl/core/resources/lsp.lua @@ -1,4 +1,9 @@ return { + { + "lvimuser/lsp-inlayhints.nvim", + opts = {} + }, + { "neovim/nvim-lspconfig", branch = "master", diff --git a/lua/tvl/core/resources/settings.lua b/lua/tvl/core/resources/settings.lua index aaaac78..3fc2c7c 100755 --- a/lua/tvl/core/resources/settings.lua +++ b/lua/tvl/core/resources/settings.lua @@ -9,7 +9,6 @@ vim.api.nvim_create_autocmd("User", { end, }) -util.lazy_notify() util.load("options") return {} diff --git a/lua/tvl/core/resources/ui.lua b/lua/tvl/core/resources/ui.lua index 3380436..d5b0a3f 100755 --- a/lua/tvl/core/resources/ui.lua +++ b/lua/tvl/core/resources/ui.lua @@ -11,6 +11,11 @@ return { }, }, opts = { + icons = { + ERROR = " ", + INFO = " ", + WARN = " ", + }, timeout = 3000, max_height = function() return math.floor(vim.o.lines * 0.75) @@ -36,7 +41,8 @@ return { options = { diagnostics = "nvim_lsp", -- | "nvim_lsp" | "coc", -- separator_style = "", -- | "thick" | "thin" | "slope" | { 'any', 'any' }, - separator_style = { "", "" }, -- | "thick" | "thin" | { 'any', 'any' }, + -- separator_style = { "", "" }, -- | "thick" | "thin" | { 'any', 'any' }, + separator_style = "slant", -- | "thick" | "thin" | { 'any', 'any' }, indicator = { -- icon = " ", -- style = 'icon', @@ -366,34 +372,32 @@ return { "folke/noice.nvim", event = "VeryLazy", opts = { - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, cmdline = { view = "cmdline", format = { cmdline = { icon = "  " }, search_down = { icon = "  󰄼" }, search_up = { icon = "  " }, - lua = {icon = " "} + lua = { icon = " " }, }, }, lsp = { progress = { enabled = true }, hover = { enabled = false }, signature = { enabled = false }, + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, }, routes = { { filter = { event = "msg_show", - kind = "", - find = "written", + find = "%d+L, %d+B", }, - opts = { skip = true }, }, }, }, diff --git a/lua/tvl/util.lua b/lua/tvl/util.lua index dde8da9..ff54a1e 100755 --- a/lua/tvl/util.lua +++ b/lua/tvl/util.lua @@ -71,42 +71,6 @@ M.set_root = function(dir) vim.api.nvim_set_current_dir(dir) end -M.lazy_notify = function() - local notifs = {} - local function temp(...) - table.insert(notifs, vim.F.pack_len(...)) - end - - local orig = vim.notify - vim.notify = temp - - local timer = vim.loop.new_timer() - local check = vim.loop.new_check() - - local replay = function() - timer:stop() - check:stop() - if vim.notify == temp then - vim.notify = orig -- put back the original notify if needed - end - vim.schedule(function() - ---@diagnostic disable-next-line: no-unknown - for _, notif in ipairs(notifs) do - vim.notify(vim.F.unpack_len(notif)) - end - end) - end - - -- wait till vim.notify has been replaced - check:start(function() - if vim.notify ~= temp then - replay() - end - end) - -- or if it took more than 500ms, then something went wrong - timer:start(500, 0, replay) -end - ---@param type "ivy" | "dropdown" | "cursor" | nil M.telescope_theme = function(type) if type == nil then