diff options
author | John Drouhard <john@drouhard.dev> | 2022-11-23 10:06:36 -0600 |
---|---|---|
committer | John Drouhard <john@drouhard.dev> | 2022-12-08 11:31:56 -0600 |
commit | 9f035559defd9d575f37fd825954610065d9cf96 (patch) | |
tree | 53d4bb16095fafb481aacdfe6e52febbfd66327c /runtime/lua/vim/lsp.lua | |
parent | 5e0c74cd82ce75510b15e63a1b0b51cf70cdf47f (diff) | |
download | rneovim-9f035559defd9d575f37fd825954610065d9cf96.tar.gz rneovim-9f035559defd9d575f37fd825954610065d9cf96.tar.bz2 rneovim-9f035559defd9d575f37fd825954610065d9cf96.zip |
feat(lsp): initial support for semantic token highlighting
* credit to @smolck and @theHamsta for their contributions in laying the
groundwork for this feature and for their work on some of the helper
utility functions and tests
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r-- | runtime/lua/vim/lsp.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 9c42e9df52..3d3c856fcb 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -4,6 +4,7 @@ local lsp_rpc = require('vim.lsp.rpc') local protocol = require('vim.lsp.protocol') local util = require('vim.lsp.util') local sync = require('vim.lsp.sync') +local semantic_tokens = require('vim.lsp.semantic_tokens') local api = vim.api local nvim_err_writeln, nvim_buf_get_lines, nvim_command, nvim_buf_get_option, nvim_exec_autocmds = @@ -25,6 +26,7 @@ local lsp = { buf = require('vim.lsp.buf'), diagnostic = require('vim.lsp.diagnostic'), codelens = require('vim.lsp.codelens'), + semantic_tokens = semantic_tokens, util = util, -- Allow raw RPC access. @@ -56,6 +58,8 @@ lsp._request_name_to_capability = { ['textDocument/formatting'] = { 'documentFormattingProvider' }, ['textDocument/completion'] = { 'completionProvider' }, ['textDocument/documentHighlight'] = { 'documentHighlightProvider' }, + ['textDocument/semanticTokens/full'] = { 'semanticTokensProvider' }, + ['textDocument/semanticTokens/full/delta'] = { 'semanticTokensProvider' }, } -- TODO improve handling of scratch buffers with LSP attached. @@ -1526,6 +1530,11 @@ function lsp.start_client(config) -- TODO(ashkan) handle errors. pcall(config.on_attach, client, bufnr) end + + if vim.tbl_get(client.server_capabilities, 'semanticTokensProvider', 'full') then + semantic_tokens.start(bufnr, client.id) + end + client.attached_buffers[bufnr] = true end |