1
0
Fork 0

nvim: use more official TS plugins, update omnisharp

This commit is contained in:
Vladimír Dudr 2024-04-24 23:02:30 +02:00
parent 70c7d5528e
commit 44a0112747
3 changed files with 104 additions and 143 deletions

View file

@ -1,11 +1,11 @@
local M = {}
local function toggle_win_opt(name)
local newval = not vim.api.nvim_win_get_option(0, name)
vim.api.nvim_win_set_option(
0,
local newval = not vim.api.nvim_get_option_value(name, { win = 0 })
vim.api.nvim_set_option_value(
name,
newval
newval,
{ win = 0 }
)
if newval then
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>od', toggle_current_win_diagnostic, { desc = 'Toggle diagnostic' })
vim.keymap.set('n', '<leader>of', function()
if (vim.api.nvim_win_get_option(0, 'foldmethod') ~= 'marker') then
vim.api.nvim_win_set_option(0, 'foldmethod', 'marker')
vim.api.nvim_win_set_option(0, 'foldlevel', 0)
if (vim.api.nvim_get_option_value('foldmethod', { win = 0 }) ~= 'marker') then
vim.api.nvim_set_option_value('foldmethod', 'marker', { win = 0 })
vim.api.nvim_set_option_value('foldlevel', 0, { win = 0 })
else
vim.api.nvim_win_set_option(0, 'foldmethod', 'expr')
vim.api.nvim_win_set_option(0, 'foldlevel', 99)
vim.api.nvim_set_option_value('foldmethod', 'expr', { win = 0 })
vim.api.nvim_set_option_value('foldlevel', 99, { win = 0 })
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' })
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 -d -w0', @\")<cr><esc>", { desc = 'Decode from base64' })

View file

@ -33,14 +33,19 @@ local server_configs = function()
handlers = {
['textDocument/definition'] = require('omnisharp_extended').handler,
},
settings = {
FormattingOptions = {
EnableEditorConfigSupport = true,
OrganizeImportsOnFormat = true
},
RoslynExtensionsOptions = {
EnableAnalyzersSupport = true,
EnableImportCompletion = true,
AnalyzeOpenDocumentsOnly = 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 = {
-- {{{
@ -144,9 +149,9 @@ local function on_attach(args) -- {{{
return
end
if (client.server_capabilities.documentSymbolProvider) then
navic_attach(client, bufnr)
end
-- if (client.server_capabilities.documentSymbolProvider) then
-- navic_attach(client, bufnr)
-- end
-- Mappings.
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', '<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(
-- { '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
client.server_capabilities.semanticTokensProvider.legend = {
tokenModifiers = { 'static' },
@ -302,6 +298,7 @@ local function on_attach(args) -- {{{
},
}
end
-- }}}
update_attached(bufnr)

View file

@ -1,67 +1,15 @@
local M = {
'nvim-treesitter/nvim-treesitter',
dependencies = {
'nvim-treesitter/playground',
'nvim-treesitter/nvim-treesitter-textobjects',
'nvim-treesitter/nvim-treesitter-refactor',
'nvim-treesitter/nvim-treesitter-context',
-- { 'yioneko/nvim-yati', tag = 'legacy' },
-- { dir = '/home/sogun/devel/nvim-yati/', }
},
event = 'BufRead',
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',
},
-- }}}
build = ':TSUpdate',
}
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()
local ts_parsers = require 'nvim-treesitter.parsers'.get_parser_configs()
-- ts_parsers.xml = {
@ -90,70 +38,85 @@ function M.config()
ignore_install = {},
auto_install = true,
sync_install = false,
highlight = {
enable = true,
disable = { 'help' },
},
playground = { enable = true },
-- yati = { enable = true },
incremental_selection = {
enable = true,
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',
modules = {
refactor = {
highlight_current_scope = { enable = true },
smart_rename = {
enable = true,
-- Assign keymaps to false to disable them, e.g. `smart_rename = false`.
keymaps = {
smart_rename = '<Leader>er',
},
},
swap_previous = {
['<leader>eP'] = '@parameter.inner',
navigation = {
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,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
-- You can optionally set descriptions to the mappings (used in the desc parameter of
-- nvim_buf_set_keymap) which plugins like which-key display
['ic'] = { query = '@class.inner', desc = 'Select inner part of a class region' },
},
highlight = {
enable = true,
disable = { 'help' },
},
indent = {
disable = { 'php' }, -- php indent SUCKS A LOT
enable = true,
},
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')
--
-- 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
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
-- You can optionally set descriptions to the mappings (used in the desc parameter of
-- 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,
},
},
}