nvim: use more official TS plugins, update omnisharp
This commit is contained in:
parent
70c7d5528e
commit
44a0112747
3 changed files with 104 additions and 143 deletions
|
@ -1,11 +1,11 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local function toggle_win_opt(name)
|
local function toggle_win_opt(name)
|
||||||
local newval = not vim.api.nvim_win_get_option(0, name)
|
local newval = not vim.api.nvim_get_option_value(name, { win = 0 })
|
||||||
vim.api.nvim_win_set_option(
|
vim.api.nvim_set_option_value(
|
||||||
0,
|
|
||||||
name,
|
name,
|
||||||
newval
|
newval,
|
||||||
|
{ win = 0 }
|
||||||
)
|
)
|
||||||
if newval then
|
if newval then
|
||||||
vim.notify(name .. ' is on')
|
vim.notify(name .. ' is on')
|
||||||
|
@ -47,17 +47,18 @@ function M.setup()
|
||||||
vim.keymap.set('n', '<leader>oR', require('configs.options').setup, { desc = 'RESET' })
|
vim.keymap.set('n', '<leader>oR', require('configs.options').setup, { desc = 'RESET' })
|
||||||
vim.keymap.set('n', '<leader>od', toggle_current_win_diagnostic, { desc = 'Toggle diagnostic' })
|
vim.keymap.set('n', '<leader>od', toggle_current_win_diagnostic, { desc = 'Toggle diagnostic' })
|
||||||
vim.keymap.set('n', '<leader>of', function()
|
vim.keymap.set('n', '<leader>of', function()
|
||||||
if (vim.api.nvim_win_get_option(0, 'foldmethod') ~= 'marker') then
|
if (vim.api.nvim_get_option_value('foldmethod', { win = 0 }) ~= 'marker') then
|
||||||
vim.api.nvim_win_set_option(0, 'foldmethod', 'marker')
|
vim.api.nvim_set_option_value('foldmethod', 'marker', { win = 0 })
|
||||||
vim.api.nvim_win_set_option(0, 'foldlevel', 0)
|
vim.api.nvim_set_option_value('foldlevel', 0, { win = 0 })
|
||||||
else
|
else
|
||||||
vim.api.nvim_win_set_option(0, 'foldmethod', 'expr')
|
vim.api.nvim_set_option_value('foldmethod', 'expr', { win = 0 })
|
||||||
vim.api.nvim_win_set_option(0, 'foldlevel', 99)
|
vim.api.nvim_set_option_value('foldlevel', 99, { win = 0 })
|
||||||
end
|
end
|
||||||
vim.notify('Fdm: ' .. vim.api.nvim_win_get_option(0, 'foldmethod'))
|
vim.notify('Fdm: ' .. vim.api.nvim_get_option_value('foldmethod', { win = 0 }))
|
||||||
end, { desc = 'Toggle foldmethod marker/expr' })
|
end, { desc = 'Toggle foldmethod marker/expr' })
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>di', '<cmd>Inspect<CR>', { desc = 'Inspect' })
|
vim.keymap.set('n', '<leader>di', '<cmd>Inspect<CR>', { desc = 'Inspect' })
|
||||||
|
vim.keymap.set('n', '<leader>dt', '<cmd>InspectTree<CR>', { desc = 'InspectTree' })
|
||||||
|
|
||||||
vim.keymap.set('x', '<leader>eB', "c<c-r>=system('base64 -w0', @\")<cr><esc>", { desc = 'Encode to base64' })
|
vim.keymap.set('x', '<leader>eB', "c<c-r>=system('base64 -w0', @\")<cr><esc>", { desc = 'Encode to base64' })
|
||||||
vim.keymap.set('x', '<leader>eb', "c<c-r>=system('base64 -d -w0', @\")<cr><esc>", { desc = 'Decode from base64' })
|
vim.keymap.set('x', '<leader>eb', "c<c-r>=system('base64 -d -w0', @\")<cr><esc>", { desc = 'Decode from base64' })
|
||||||
|
|
|
@ -33,14 +33,19 @@ local server_configs = function()
|
||||||
handlers = {
|
handlers = {
|
||||||
['textDocument/definition'] = require('omnisharp_extended').handler,
|
['textDocument/definition'] = require('omnisharp_extended').handler,
|
||||||
},
|
},
|
||||||
|
settings = {
|
||||||
|
FormattingOptions = {
|
||||||
|
EnableEditorConfigSupport = true,
|
||||||
|
OrganizeImportsOnFormat = true
|
||||||
|
},
|
||||||
|
RoslynExtensionsOptions = {
|
||||||
|
EnableAnalyzersSupport = true,
|
||||||
|
EnableImportCompletion = true,
|
||||||
|
AnalyzeOpenDocumentsOnly = true,
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
cmd = { 'omnisharp', 'RoslynExtensionsOptions:EnableDecompilationSupport=true' },
|
cmd = { 'omnisharp', 'RoslynExtensionsOptions:EnableDecompilationSupport=true' },
|
||||||
enable_editorconfig_support = true,
|
|
||||||
enable_ms_build_load_projects_on_demand = false,
|
|
||||||
enable_roslyn_analyzers = true,
|
|
||||||
organize_imports_on_format = true,
|
|
||||||
enable_import_completion = true,
|
|
||||||
sdk_include_prereleases = true,
|
|
||||||
analyze_open_documents_only = true,
|
|
||||||
}, -- }}}
|
}, -- }}}
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
-- {{{
|
-- {{{
|
||||||
|
@ -144,9 +149,9 @@ local function on_attach(args) -- {{{
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (client.server_capabilities.documentSymbolProvider) then
|
-- if (client.server_capabilities.documentSymbolProvider) then
|
||||||
navic_attach(client, bufnr)
|
-- navic_attach(client, bufnr)
|
||||||
end
|
-- end
|
||||||
|
|
||||||
-- Mappings.
|
-- Mappings.
|
||||||
local function mkOpts(desc)
|
local function mkOpts(desc)
|
||||||
|
@ -219,17 +224,8 @@ local function on_attach(args) -- {{{
|
||||||
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, mkOpts('LSP references'))
|
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, mkOpts('LSP references'))
|
||||||
vim.keymap.set('n', '<leader>cr', '<Cmd>Trouble lsp_references<CR>', mkOpts('LSP references'))
|
vim.keymap.set('n', '<leader>cr', '<Cmd>Trouble lsp_references<CR>', mkOpts('LSP references'))
|
||||||
vim.keymap.set('n', '<leader>cs', '<Cmd>Telescope lsp_document_symbols<CR>', mkOpts('LSP document symbols'))
|
vim.keymap.set('n', '<leader>cs', '<Cmd>Telescope lsp_document_symbols<CR>', mkOpts('LSP document symbols'))
|
||||||
-- vim.keymap.set(
|
|
||||||
-- { 'v', 'n' }, '<leader>F', function()
|
|
||||||
-- vim.lsp.buf.format({ async = true, filter = formatting_filter })
|
|
||||||
-- end,
|
|
||||||
-- mkOpts('Lsp Format')
|
|
||||||
-- )
|
|
||||||
--
|
|
||||||
-- if (formatting_filter(client)) then
|
|
||||||
-- vim.api.nvim_set_option_value('formatexpr', 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})', { buf = bufnr })
|
|
||||||
-- end
|
|
||||||
|
|
||||||
|
-- fix omnisharp {{{
|
||||||
if client.name == 'omnisharp' then
|
if client.name == 'omnisharp' then
|
||||||
client.server_capabilities.semanticTokensProvider.legend = {
|
client.server_capabilities.semanticTokensProvider.legend = {
|
||||||
tokenModifiers = { 'static' },
|
tokenModifiers = { 'static' },
|
||||||
|
@ -302,6 +298,7 @@ local function on_attach(args) -- {{{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
update_attached(bufnr)
|
update_attached(bufnr)
|
||||||
|
|
|
@ -1,67 +1,15 @@
|
||||||
local M = {
|
local M = {
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
'nvim-treesitter/playground',
|
|
||||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||||
|
'nvim-treesitter/nvim-treesitter-refactor',
|
||||||
|
'nvim-treesitter/nvim-treesitter-context',
|
||||||
-- { 'yioneko/nvim-yati', tag = 'legacy' },
|
-- { 'yioneko/nvim-yati', tag = 'legacy' },
|
||||||
-- { dir = '/home/sogun/devel/nvim-yati/', }
|
-- { dir = '/home/sogun/devel/nvim-yati/', }
|
||||||
},
|
},
|
||||||
event = 'BufRead',
|
build = ':TSUpdate',
|
||||||
keys = {
|
|
||||||
{ '<leader>dp', '<cmd>TSPlaygroundToggle<CR>', desc = 'TSPlaygroundToggle' }
|
|
||||||
},
|
|
||||||
-- cmd {{{
|
|
||||||
cmd = {
|
|
||||||
'TSBufDisable',
|
|
||||||
'TSBufEnable',
|
|
||||||
'TSBufToggle',
|
|
||||||
'TSCaptureUnderCursor',
|
|
||||||
'TSConfigInfo',
|
|
||||||
'TSDisable',
|
|
||||||
'TSEditQuery',
|
|
||||||
'TSEditQueryUserAfter',
|
|
||||||
'TSEnable',
|
|
||||||
'TSHighlightCapturesUnderCursor',
|
|
||||||
'TSInstall',
|
|
||||||
'TSInstallFromGrammar',
|
|
||||||
'TSInstallInfo',
|
|
||||||
'TSInstallSync',
|
|
||||||
'TSModuleInfo',
|
|
||||||
'TSNodeUnderCursor',
|
|
||||||
'TSPlaygroundToggle',
|
|
||||||
'TSTextobjectBuiltinF',
|
|
||||||
'TSTextobjectBuiltinT',
|
|
||||||
'TSTextobjectBuiltinf',
|
|
||||||
'TSTextobjectBuiltint',
|
|
||||||
'TSTextobjectGotoNextEnd',
|
|
||||||
'TSTextobjectGotoNextStart',
|
|
||||||
'TSTextobjectGotoPreviousEnd',
|
|
||||||
'TSTextobjectGotoPreviousStart',
|
|
||||||
'TSTextobjectPeekDefinitionCode',
|
|
||||||
'TSTextobjectRepeatLastMove',
|
|
||||||
'TSTextobjectRepeatLastMoveNext',
|
|
||||||
'TSTextobjectRepeatLastMoveOpposite',
|
|
||||||
'TSTextobjectRepeatLastMovePrevious',
|
|
||||||
'TSTextobjectSelect',
|
|
||||||
'TSTextobjectSwapNext',
|
|
||||||
'TSTextobjectSwapPrevious',
|
|
||||||
'TSToggle',
|
|
||||||
'TSUninstall',
|
|
||||||
'TSUpdate',
|
|
||||||
'TSUpdateSync',
|
|
||||||
},
|
|
||||||
-- }}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.init()
|
|
||||||
local aug = vim.api.nvim_create_augroup('treesitterUpdate', { clear = true })
|
|
||||||
vim.api.nvim_create_autocmd('User', {
|
|
||||||
pattern = { 'LazySync' },
|
|
||||||
group = aug,
|
|
||||||
command = 'TSUpdate',
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.config()
|
function M.config()
|
||||||
local ts_parsers = require 'nvim-treesitter.parsers'.get_parser_configs()
|
local ts_parsers = require 'nvim-treesitter.parsers'.get_parser_configs()
|
||||||
-- ts_parsers.xml = {
|
-- ts_parsers.xml = {
|
||||||
|
@ -90,70 +38,85 @@ function M.config()
|
||||||
ignore_install = {},
|
ignore_install = {},
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
sync_install = false,
|
sync_install = false,
|
||||||
highlight = {
|
modules = {
|
||||||
enable = true,
|
refactor = {
|
||||||
disable = { 'help' },
|
highlight_current_scope = { enable = true },
|
||||||
},
|
smart_rename = {
|
||||||
playground = { enable = true },
|
enable = true,
|
||||||
-- yati = { enable = true },
|
-- Assign keymaps to false to disable them, e.g. `smart_rename = false`.
|
||||||
incremental_selection = {
|
keymaps = {
|
||||||
enable = true,
|
smart_rename = '<Leader>er',
|
||||||
keymaps = {
|
},
|
||||||
init_selection = 'gnn',
|
|
||||||
node_incremental = '+',
|
|
||||||
scope_incremental = 'grc',
|
|
||||||
node_decremental = '-',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
indent = {
|
|
||||||
disable = { 'php' }, -- php indent SUCKS A LOT
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
textobjects = {
|
|
||||||
swap = {
|
|
||||||
enable = true,
|
|
||||||
swap_next = {
|
|
||||||
['<leader>ep'] = '@parameter.inner',
|
|
||||||
},
|
},
|
||||||
swap_previous = {
|
navigation = {
|
||||||
['<leader>eP'] = '@parameter.inner',
|
enable = true,
|
||||||
|
-- Assign keymaps to false to disable them, e.g. `goto_definition = false`.
|
||||||
|
keymaps = {
|
||||||
|
goto_definition = 'gd',
|
||||||
|
list_definitions = 'gtD',
|
||||||
|
list_definitions_toc = 'gO',
|
||||||
|
goto_next_usage = ']u',
|
||||||
|
goto_previous_usage = '[u',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
select = {
|
context = {
|
||||||
enable = true,
|
enable = true,
|
||||||
-- Automatically jump forward to textobj, similar to targets.vim
|
},
|
||||||
lookahead = true,
|
highlight = {
|
||||||
keymaps = {
|
enable = true,
|
||||||
-- You can use the capture groups defined in textobjects.scm
|
disable = { 'help' },
|
||||||
['af'] = '@function.outer',
|
},
|
||||||
['if'] = '@function.inner',
|
indent = {
|
||||||
['ac'] = '@class.outer',
|
disable = { 'php' }, -- php indent SUCKS A LOT
|
||||||
-- You can optionally set descriptions to the mappings (used in the desc parameter of
|
enable = true,
|
||||||
-- nvim_buf_set_keymap) which plugins like which-key display
|
},
|
||||||
['ic'] = { query = '@class.inner', desc = 'Select inner part of a class region' },
|
textobjects = {
|
||||||
|
swap = {
|
||||||
|
enable = true,
|
||||||
|
swap_next = {
|
||||||
|
['<leader>ep'] = '@parameter.inner',
|
||||||
|
},
|
||||||
|
swap_previous = {
|
||||||
|
['<leader>eP'] = '@parameter.inner',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
-- You can choose the select mode (default is charwise 'v')
|
select = {
|
||||||
--
|
enable = true,
|
||||||
-- Can also be a function which gets passed a table with the keys
|
-- Automatically jump forward to textobj, similar to targets.vim
|
||||||
-- * query_string: eg '@function.inner'
|
lookahead = true,
|
||||||
-- * method: eg 'v' or 'o'
|
keymaps = {
|
||||||
-- and should return the mode ('v', 'V', or '<c-v>') or a table
|
-- You can use the capture groups defined in textobjects.scm
|
||||||
-- mapping query_strings to modes.
|
['af'] = '@function.outer',
|
||||||
selection_modes = {
|
['if'] = '@function.inner',
|
||||||
['@parameter.outer'] = 'v', -- charwise
|
['ac'] = '@class.outer',
|
||||||
['@function.outer'] = 'V', -- linewise
|
-- You can optionally set descriptions to the mappings (used in the desc parameter of
|
||||||
['@class.outer'] = '<c-v>', -- blockwise
|
-- nvim_buf_set_keymap) which plugins like which-key display
|
||||||
|
['ic'] = { query = '@class.inner', desc = 'Select inner part of a class region' },
|
||||||
|
},
|
||||||
|
-- You can choose the select mode (default is charwise 'v')
|
||||||
|
--
|
||||||
|
-- Can also be a function which gets passed a table with the keys
|
||||||
|
-- * query_string: eg '@function.inner'
|
||||||
|
-- * method: eg 'v' or 'o'
|
||||||
|
-- and should return the mode ('v', 'V', or '<c-v>') or a table
|
||||||
|
-- mapping query_strings to modes.
|
||||||
|
selection_modes = {
|
||||||
|
['@parameter.outer'] = 'v', -- charwise
|
||||||
|
['@function.outer'] = 'V', -- linewise
|
||||||
|
['@class.outer'] = '<c-v>', -- blockwise
|
||||||
|
},
|
||||||
|
-- If you set this to `true` (default is `false`) then any textobject is
|
||||||
|
-- extended to include preceding or succeeding whitespace. Succeeding
|
||||||
|
-- whitespace has priority in order to act similarly to eg the built-in
|
||||||
|
-- `ap`.
|
||||||
|
--
|
||||||
|
-- Can also be a function which gets passed a table with the keys
|
||||||
|
-- * query_string: eg '@function.inner'
|
||||||
|
-- * selection_mode: eg 'v'
|
||||||
|
-- and should return true of false
|
||||||
|
include_surrounding_whitespace = true,
|
||||||
},
|
},
|
||||||
-- If you set this to `true` (default is `false`) then any textobject is
|
|
||||||
-- extended to include preceding or succeeding whitespace. Succeeding
|
|
||||||
-- whitespace has priority in order to act similarly to eg the built-in
|
|
||||||
-- `ap`.
|
|
||||||
--
|
|
||||||
-- Can also be a function which gets passed a table with the keys
|
|
||||||
-- * query_string: eg '@function.inner'
|
|
||||||
-- * selection_mode: eg 'v'
|
|
||||||
-- and should return true of false
|
|
||||||
include_surrounding_whitespace = true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue