diff --git a/dot_config/nvim/lua/configs/keys.lua b/dot_config/nvim/lua/configs/keys.lua index 5cfb403..ee7387b 100644 --- a/dot_config/nvim/lua/configs/keys.lua +++ b/dot_config/nvim/lua/configs/keys.lua @@ -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', 'oR', require('configs.options').setup, { desc = 'RESET' }) vim.keymap.set('n', 'od', toggle_current_win_diagnostic, { desc = 'Toggle diagnostic' }) vim.keymap.set('n', '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', 'di', 'Inspect', { desc = 'Inspect' }) + vim.keymap.set('n', 'dt', 'InspectTree', { desc = 'InspectTree' }) vim.keymap.set('x', 'eB', "c=system('base64 -w0', @\")", { desc = 'Encode to base64' }) vim.keymap.set('x', 'eb', "c=system('base64 -d -w0', @\")", { desc = 'Decode from base64' }) diff --git a/dot_config/nvim/lua/configs/packages/lsp.lua b/dot_config/nvim/lua/configs/packages/lsp.lua index 7e2a065..9a57a9a 100644 --- a/dot_config/nvim/lua/configs/packages/lsp.lua +++ b/dot_config/nvim/lua/configs/packages/lsp.lua @@ -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', 'cr', 'Trouble lsp_references', mkOpts('LSP references')) vim.keymap.set('n', 'cs', 'Telescope lsp_document_symbols', mkOpts('LSP document symbols')) - -- vim.keymap.set( - -- { 'v', 'n' }, '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) diff --git a/dot_config/nvim/lua/configs/packages/treesitter.lua b/dot_config/nvim/lua/configs/packages/treesitter.lua index 525ff33..61f6b0c 100644 --- a/dot_config/nvim/lua/configs/packages/treesitter.lua +++ b/dot_config/nvim/lua/configs/packages/treesitter.lua @@ -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 = { - { 'dp', 'TSPlaygroundToggle', 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 = { - ['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 = 'er', + }, }, - swap_previous = { - ['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 = { + ['ep'] = '@parameter.inner', + }, + swap_previous = { + ['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 '') or a table - -- mapping query_strings to modes. - selection_modes = { - ['@parameter.outer'] = 'v', -- charwise - ['@function.outer'] = 'V', -- linewise - ['@class.outer'] = '', -- 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 '') or a table + -- mapping query_strings to modes. + selection_modes = { + ['@parameter.outer'] = 'v', -- charwise + ['@function.outer'] = 'V', -- linewise + ['@class.outer'] = '', -- 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, }, }, }