feat: Properly handle omnisharp semanticTokens

We need to massage the tokens a bit.
This commit is contained in:
Jeremy Wall 2023-08-23 13:40:46 -04:00
parent 9364b5c328
commit 70c86fae96
3 changed files with 32 additions and 21 deletions

View File

@ -38,7 +38,6 @@
"tree-sitter-toml"
"tree-sitter-yaml"
"tree-sitter-json"
#"tree-sitter-ini"
"tree-sitter-html"
"tree-sitter-css"
"tree-sitter-nix"

View File

@ -64,14 +64,26 @@ local vim_pid = vim.fn.getpid()
-- "FormatterOptions:EnableEditorConfigSupport=true"
local omnisharp_cmd = { 'omnisharp', '--languageserver', '-v', '--hostPID', tostring(vim_pid), }
local function toSnakeCase(str)
return string.gsub(str, "%s*[- ]%s*", "_")
end
lspconfig.omnisharp.setup {
cmd = omnisharp_cmd,
enable_roslyn_analyzers = true,
enable_editorconfig_support = true,
enable_import_completion = true,
-- Omnisharp has issues with the semanticTokens feature. disable it for this language server.
-- Omnisharp has issues with the semanticTokens feature we need to massage it a bit.
on_attach = function(client, bufnr)
client.server_capabilities.semanticTokensProvider = nil
-- https://github.com/OmniSharp/omnisharp-roslyn/issues/2483#issuecomment-1492605642
local tokenModifiers = client.server_capabilities.semanticTokensProvider.legend.tokenModifiers
for i, v in ipairs(tokenModifiers) do
tokenModifiers[i] = toSnakeCase(v)
end
local tokenTypes = client.server_capabilities.semanticTokensProvider.legend.tokenTypes
for i, v in ipairs(tokenTypes) do
tokenTypes[i] = toSnakeCase(v)
end
end,
handlers = {
["textDocument/definition"] = require('omnisharp_extended').handler,
@ -187,21 +199,21 @@ require('nvim-treesitter.configs').setup {
extended_mode = true,
max_file_lines = nil,
},
textobjects = {
select = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- You can use the capture groups defined in textobjects.scm
['aa'] = '@parameter.outer',
['ia'] = '@parameter.inner',
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
},
},
},
--textobjects = {
-- select = {
-- enable = true,
-- lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
-- keymaps = {
-- -- You can use the capture groups defined in textobjects.scm
-- ['aa'] = '@parameter.outer',
-- ['ia'] = '@parameter.inner',
-- ['af'] = '@function.outer',
-- ['if'] = '@function.inner',
-- ['ac'] = '@class.outer',
-- ['ic'] = '@class.inner',
-- },
-- },
--},
--incremental_selection = {
-- enable = true,
-- keymaps = {

6
nix/darwin/flake.lock generated
View File

@ -34,12 +34,12 @@
},
"locked": {
"lastModified": 1,
"narHash": "sha256-LdDXr6idLkkTeHwlq0ZA7kri4HMr124xABHowvooD/c=",
"path": "/nix/store/hhwybysgssx8f4ivff8yhagm6iyqgis9-source/nix/base-system",
"narHash": "sha256-RQLwfX1ZM8lLATzqM41ZhBnB+LRK71D3Q5nyaG3c30A=",
"path": "/nix/store/3yf62sm1x6h8bb01hxwln2sgi1czwcqy-source/nix/base-system",
"type": "path"
},
"original": {
"path": "/nix/store/hhwybysgssx8f4ivff8yhagm6iyqgis9-source/nix/base-system",
"path": "/nix/store/3yf62sm1x6h8bb01hxwln2sgi1czwcqy-source/nix/base-system",
"type": "path"
}
},