diff --git a/lua/cosmic/config/examples/config.lua b/lua/cosmic/config/examples/config.lua index 3c28e85..c260be1 100644 --- a/lua/cosmic/config/examples/config.lua +++ b/lua/cosmic/config/examples/config.lua @@ -8,6 +8,8 @@ local config = { border = 'rounded', -- LSP settings lsp = { + -- Enable/disable inlay hints + inlay_hint = false, -- True/false or table of filetypes {'.ts', '.js',} format_on_save = true, -- Time in MS before format timeout diff --git a/lua/cosmic/core/user.lua b/lua/cosmic/core/user.lua index e32433b..6bf6a8a 100644 --- a/lua/cosmic/core/user.lua +++ b/lua/cosmic/core/user.lua @@ -19,6 +19,7 @@ local default_config = { }, }, lsp = { + inlay_hint = false, format_on_save = true, -- true/false or table of filetypes {'.ts', '.js',} format_timeout = 2000, rename_notification = true, diff --git a/lua/cosmic/lsp/providers/defaults.lua b/lua/cosmic/lsp/providers/defaults.lua index 0e87a71..8db941b 100644 --- a/lua/cosmic/lsp/providers/defaults.lua +++ b/lua/cosmic/lsp/providers/defaults.lua @@ -12,6 +12,10 @@ function M.on_attach(client, bufnr) -- Enable completion triggered by buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') + if user_config.lsp.inlay_hint and client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint(bufnr, true) + end + if client.supports_method('textDocument/formatting') then -- set up :LspFormat for clients that are capable vim.cmd(string.format("command! LspFormat lua require('cosmic.utils.lsp').format(%s)", bufnr)) diff --git a/lua/cosmic/lsp/providers/lua_ls.lua b/lua/cosmic/lsp/providers/lua_ls.lua index 45ff535..7b2ed47 100644 --- a/lua/cosmic/lsp/providers/lua_ls.lua +++ b/lua/cosmic/lsp/providers/lua_ls.lua @@ -1,6 +1,9 @@ return { settings = { Lua = { + hint = { + enable = true, + }, diagnostics = { -- Get the language server to recognize the `vim` global globals = { 'vim' }, diff --git a/lua/cosmic/lsp/providers/tsserver.lua b/lua/cosmic/lsp/providers/tsserver.lua index 0617323..4c9271f 100644 --- a/lua/cosmic/lsp/providers/tsserver.lua +++ b/lua/cosmic/lsp/providers/tsserver.lua @@ -1,6 +1,8 @@ local default_on_attach = require('cosmic.lsp.providers.defaults').on_attach local M = {} +M.init_options = require('nvim-lsp-ts-utils').init_options + function M.on_attach(client, bufnr) default_on_attach(client, bufnr)