diff options
Diffstat (limited to '')
| -rw-r--r-- | .vim/lua/plugins.lua | 301 | ||||
| -rw-r--r-- | .vim/lua/plugins/_completion.lua | 48 | ||||
| -rw-r--r-- | .vim/lua/plugins/_lightbulb.lua | 19 | ||||
| -rw-r--r-- | .vim/lua/plugins/_lsp.lua | 213 | ||||
| -rw-r--r-- | .vim/lua/plugins/_markdown.lua | 21 | ||||
| -rw-r--r-- | .vim/lua/plugins/_neuron.lua | 15 | ||||
| -rw-r--r-- | .vim/lua/plugins/_telescope.lua | 181 | ||||
| -rw-r--r-- | .vim/lua/plugins/_treesitter.lua | 42 | ||||
| -rw-r--r-- | .vim/lua/plugins/_ultisnips.lua | 2 |
9 files changed, 520 insertions, 322 deletions
diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua index 6ec9e61..d41024e 100644 --- a/.vim/lua/plugins.lua +++ b/.vim/lua/plugins.lua @@ -4,154 +4,167 @@ local g = vim.g local u = require('utils') function disable_distribution_plugins() - g.loaded_gzip = 1 - g.loaded_tar = 1 - g.loaded_tarPlugin = 1 - g.loaded_zip = 1 - g.loaded_zipPlugin = 1 - g.loaded_getscript = 1 - g.loaded_getscriptPlugin = 1 - g.loaded_vimball = 1 - g.loaded_vimballPlugin = 1 - g.loaded_matchit = 1 - -- g.loaded_matchparen = 1 - g.loaded_2html_plugin = 1 - g.loaded_logiPat = 1 - g.loaded_rrhelper = 1 - g.loaded_netrw = 1 - g.loaded_netrwPlugin = 1 - g.loaded_netrwSettings = 1 - g.loaded_netrwFileHandlers = 1 + g.loaded_gzip = 1 + g.loaded_tar = 1 + g.loaded_tarPlugin = 1 + g.loaded_zip = 1 + g.loaded_zipPlugin = 1 + g.loaded_getscript = 1 + g.loaded_getscriptPlugin = 1 + g.loaded_vimball = 1 + g.loaded_vimballPlugin = 1 + g.loaded_matchit = 1 + -- g.loaded_matchparen = 1 + g.loaded_2html_plugin = 1 + g.loaded_logiPat = 1 + g.loaded_rrhelper = 1 + g.loaded_netrw = 1 + g.loaded_netrwPlugin = 1 + g.loaded_netrwSettings = 1 + g.loaded_netrwFileHandlers = 1 end -- enable to bootstrap packer from ~/.local/share/nvim/site/pack/packer/opt/packer.nvim -- vim.cmd [[packadd packer.nvim]] return require'packer'.startup(function() - -- disable built-in plugins - disable_distribution_plugins() - - -- manage packer itself - use {'wbthomason/packer.nvim'} - - -- git status in the sign column - use {'mhinz/vim-signify', - config = "require('plugins._signify')" - } - - use {'tpope/vim-commentary'} -- auto-comment using `gcc` - use {'cohama/lexima.vim'} -- auto-close parens, brackets, etc. - use {'tpope/vim-surround'} -- edit surroundings in pairs - -- use {'neomake/neomake'} -- async job runner - use {'sbdchd/neoformat'} -- async code formatter - use {'justinmk/vim-dirvish'} -- folder browser - use {'justinmk/vim-sneak', - config = "vim.g['sneak#label'] = true" - } - - use {'neovim/nvim-lspconfig', - requires = { - {'nvim-lua/completion-nvim', - requires = {'steelsojka/completion-buffers'}, - config = "require('plugins._completion')"}, - 'kosayoda/nvim-lightbulb', - }, - config = "require('plugins._lsp')" - } - - use {'nvim-treesitter/nvim-treesitter', - requires = { - 'nvim-lua/completion-nvim', - 'nvim-treesitter/completion-treesitter', - 'nvim-treesitter/nvim-treesitter-refactor', - }, - config = "require('plugins._treesitter')" - } - - use {'nvim-telescope/telescope.nvim', - requires = { - 'nvim-lua/popup.nvim', - 'nvim-lua/plenary.nvim', - -- telescope plugins: - 'nvim-telescope/telescope-fzf-writer.nvim', - }, - config = "require('plugins._telescope')" - } - - -- polyfill for some missing stuff - use {'tjdevries/astronauta.nvim'} - - -- snippets - use {'SirVer/ultisnips', - requires = {'honza/vim-snippets'}, - config = "require('plugins._ultisnips')" - } - - use {'junegunn/vim-easy-align'} - - -- use {'tpope/vim-sleuth'} -- detect indentation - use {'nathanaelkane/vim-indent-guides', - config = "require('plugins._indent-guides')" - } - - use {'tpope/vim-repeat'} -- extend '.' to plugins - use {'sgur/vim-editorconfig'} -- implements editorconfig in vimscript - use {'michaeljsmith/vim-indent-object'} -- adds indentation text-objects - use {'kshenoy/vim-signature', disable = true} -- toggle, display and navigate marks - use {'norcalli/nvim-colorizer.lua', - config = "require('plugins._colorizer')" - } - - use {'rhysd/git-messenger.vim', - config = "require('plugins._git-messenger')" - } - - use {'rhysd/conflict-marker.vim', disable = true} - -- use {'liuchengxu/vista.vim'} -- sidebar populated by lsp, ctags, etc. - use {'kassio/neoterm', disable = true} - - -- languages - -- NOTE: these should only be loaded when they are required... - -- use {'rhysd/vim-grammarous', - -- ft = {'markdown', 'latex', 'tex'} - -- } - use {'lervag/vimtex', - ft = {'latex', 'tex'}, - config = "require('plugins._vimtex')" - } - use {'plasticboy/vim-markdown', - ft = {'markdown'}, - config = "require('plugins._markdown')" - } - use {'masukomi/vim-markdown-folding', - ft = {'markdown'} - } - use {'jjo/vim-cue', - ft = {'cue'} - } - use {'gentoo/gentoo-syntax'} - - -- multi-language support with lazy loading - -- NOTE: put language specific plugs before this to avoid conflicsts - use {'sheerun/vim-polyglot'} - - -- minimal ux - use {'junegunn/goyo.vim', - cmd = 'Goyo', - config = "require('plugins._goyo')" - } - use {'junegunn/limelight.vim', - cmd = 'Limelight', - config = "require('plugins._limelight')" - } - - use {'rktjmp/lush.nvim', - disable = true, - config="require('plugins._lush')"} - - -- vim config debugging - use {'dstein64/vim-startuptime', disable = true} - - -- local - use {'~/devel/upstream/github.com/knsh14/vim-github-link'} + -- disable built-in plugins + disable_distribution_plugins() + + -- manage packer itself + use {'wbthomason/packer.nvim'} + + -- git status in the sign column + use {'mhinz/vim-signify', + config = "require('plugins._signify')" + } + + use {'tpope/vim-commentary'} -- auto-comment using `gcc` + use {'cohama/lexima.vim'} -- auto-close parens, brackets, etc. + use {'tpope/vim-surround'} -- edit surroundings in pairs + -- use {'neomake/neomake'} -- async job runner + use {'sbdchd/neoformat'} -- async code formatter + use {'justinmk/vim-dirvish'} -- folder browser + use {'justinmk/vim-sneak', + config = "vim.g['sneak#label'] = true" + } + + use {'neovim/nvim-lspconfig', + requires = { + {'nvim-lua/completion-nvim', + requires = {'steelsojka/completion-buffers'}, + config = "require('plugins._completion')"}, + {'kosayoda/nvim-lightbulb', config = "require('plugins._lightbulb')"}, + }, + config = "require('plugins._lsp')" + } + + use {'nvim-treesitter/nvim-treesitter', + requires = { + 'nvim-lua/completion-nvim', + 'nvim-treesitter/completion-treesitter', + 'nvim-treesitter/nvim-treesitter-refactor', + }, + config = "require('plugins._treesitter')", + run = ':TSUpdate' + } + + use {'nvim-telescope/telescope.nvim', + requires = { + 'nvim-lua/popup.nvim', + 'nvim-lua/plenary.nvim', + -- telescope plugins: + 'nvim-telescope/telescope-fzf-writer.nvim', + }, + config = "require('plugins._telescope')" + } + + -- polyfill for some missing stuff + use {'tjdevries/astronauta.nvim'} + + -- snippets + use {'SirVer/ultisnips', + requires = {'honza/vim-snippets'}, + config = "require('plugins._ultisnips')" + } + + use {'junegunn/vim-easy-align'} + + -- use {'tpope/vim-sleuth'} -- detect indentation + use {'nathanaelkane/vim-indent-guides', + disable = true, + config = "require('plugins._indent-guides')" + } + + use {'tpope/vim-repeat'} -- extend '.' to plugins + use {'sgur/vim-editorconfig'} -- implements editorconfig in vimscript + use {'michaeljsmith/vim-indent-object'} -- adds indentation text-objects + use {'kshenoy/vim-signature', disable = true} -- toggle, display and navigate marks + use {'norcalli/nvim-colorizer.lua', + config = "require('plugins._colorizer')" + } + + use {'rhysd/git-messenger.vim', + config = "require('plugins._git-messenger')" + } + + use {'TimUntersberger/neogit', + cmd = 'Neogit' + } + + use {'rhysd/conflict-marker.vim', disable = true} + -- use {'liuchengxu/vista.vim'} -- sidebar populated by lsp, ctags, etc. + use {'kassio/neoterm', disable = true} + + -- zettelkasten via neuron + -- NOTE: needs telescope.nvim and plenary.nvim + use {'oberblastmeister/neuron.nvim', + branch = 'unstable', + requires = {'nvim-telescope/telescope.nvim'}, + config = "require('.plugins._neuron')" + } + + -- languages + -- NOTE: these should only be loaded when they are required... + -- use {'rhysd/vim-grammarous', + -- ft = {'markdown', 'latex', 'tex'} + -- } + use {'lervag/vimtex', + ft = {'latex', 'tex'}, + config = "require('plugins._vimtex')" + } + use {'plasticboy/vim-markdown', + ft = {'markdown'}, + config = "require('plugins._markdown')" + } + use {'masukomi/vim-markdown-folding', + ft = {'markdown'} + } + use {'jjo/vim-cue', + ft = {'cue'} + } + use {'gentoo/gentoo-syntax'} + + -- multi-language support with lazy loading + -- NOTE: put language specific plugs before this to avoid conflicsts + use {'sheerun/vim-polyglot'} + + -- minimal ux + use {'junegunn/goyo.vim', + cmd = 'Goyo', + config = "require('plugins._goyo')" + } + use {'junegunn/limelight.vim', + cmd = 'Limelight', + config = "require('plugins._limelight')" + } + + use {'rktjmp/lush.nvim',} + -- config="require('colors')"} + + -- vim config debugging + use {'dstein64/vim-startuptime', disable = true} + + -- local + use {'~/devel/upstream/github.com/knsh14/vim-github-link'} end) diff --git a/.vim/lua/plugins/_completion.lua b/.vim/lua/plugins/_completion.lua index 8a4a92e..504ab00 100644 --- a/.vim/lua/plugins/_completion.lua +++ b/.vim/lua/plugins/_completion.lua @@ -1,17 +1,53 @@ local g = vim.g local u = require('utils') +local inoremap = require('astronauta.keymap').inoremap g.completion_enable_auto_popup = true g.completion_enable_auto_signature = true g.completion_enable_auto_paren = false -g.completion_confirm_key = '<tab>' +g.completion_enable_auto_hover = true +g.completion_trigger_on_delete = true +g.completion_confirm_key = '<cr>' g.completion_enable_snippet = 'UltiSnips' +-- g.completion_matching_ignore_case = false +g.completion_matching_smart_case = true +g.completion_matching_strategy_list = {'exact', 'substring', 'fuzzy', 'all'} +g.completion_sorting = 'length' -- or: alphabet, none + g.completion_auto_change_source = true g.completion_chain_complete_list = { - {complete_items = {'lsp', 'snippet', 'buffers', 'ts', 'path'}}, - {mode = 'file'}, + {complete_items = {'lsp', 'snippet', 'buffers', 'path', 'ts'}}, + -- {mode = '<c-p>'}, + -- {mode = '<c-n>'}, + {mode = 'file'}, + {mode = 'spel'}, +} + +u.augroup2 { + completion_user = {{'BufEnter', '*', 'lua require("completion").on_attach()'}} } -u.augroup('completion', { - {'BufEnter', '*', 'lua require("completion").on_attach()'}, -}) +inoremap { '<tab>', function() require('completion').smart_tab() end } +inoremap { '<s-tab>', function() require('completion').smart_s_tab() end } +inoremap { '<c-j>', function() require('completion.source').nextCompletion() end } +inoremap { '<c-k>', function() require('completion.source').prevCompletion() end } + +-- inoremap { '<c-n>', function() +-- if vim.fn.pumvisible() == 1 then +-- vim.api.nvim_feedkeys('<c-n>') +-- else +-- require('completion').triggerCompletion() +-- end +-- end } + +-- inoremap { '<c-p>', function() +-- if vim.fn.pumvisible() == 1 then +-- vim.api.nvim_feedkeys('<c-p>') +-- else +-- require('completion').triggerCompletion() +-- end +-- end } + +-- require('utils').map('i', '<C-n>', 'pumvisible() ? "\\<C-n>" : completion#trigger_completion()', { expr = true }) +-- require('utils').map('i', '<C-p>', 'pumvisible() ? "\\<C-p>" : completion#trigger_completion()', { expr = true }) + diff --git a/.vim/lua/plugins/_lightbulb.lua b/.vim/lua/plugins/_lightbulb.lua new file mode 100644 index 0000000..cc3f941 --- /dev/null +++ b/.vim/lua/plugins/_lightbulb.lua @@ -0,0 +1,19 @@ + +require('nvim-lightbulb').update_lightbulb { + sign = { + enabled = true, + priority = 10, + }, + float = { + enabled = true, + text = '', + win_opts = {}, + }, + virtual_test = { + enabled = false + } +} + +require('utils').augroup('lightbulb', { + {'CursorHold,CursorHoldI', '*', "lua require'nvim-lightbulb'.update_lightbulb()"} +}) diff --git a/.vim/lua/plugins/_lsp.lua b/.vim/lua/plugins/_lsp.lua index 780f703..9a1a0bb 100644 --- a/.vim/lua/plugins/_lsp.lua +++ b/.vim/lua/plugins/_lsp.lua @@ -5,75 +5,172 @@ local util = require('lspconfig.util') local u = require('utils') local nnoremap = require('astronauta.keymap').nnoremap --- https://github.com/kosayoda/nvim-lightbulb -require('nvim-lightbulb').update_lightbulb { - sign = { - enabled = true, - priority = 10, - }, - float = { - enabled = true, - text = '', - win_opts = {}, - }, -} - +local M = {} local my_attach = function(client) - -- attach completion - require 'completion'.on_attach(client) - - -- lsp mappings - nnoremap { 'K', function() vim.lsp.buf.hover() end } - nnoremap { '<C-]>', function() vim.lsp.buf.definition() end } - nnoremap { 'grr', function() vim.lsp.buf.rename() end } - nnoremap { '<c-h>', function() vim.lsp.buf.signature_help() end } - nnoremap { ']d', function() vim.lsp.diagnostic.goto_next() end } - nnoremap { '[d', function() vim.lsp.diagnostic.goto_prev() end } - - -- nnoremap <silent> gD <cmd> lua vim.lsp.buf.declaration()<CR> - -- nnoremap <silent> gd <cmd> lua vim.lsp.buf.definition()<CR> - -- nnoremap <silent> gT <cmd> lua vim.lsp.buf.type_definition()<CR> - -- nnoremap <silent> gI <cmd> lua vim.lsp.buf.implementation()<CR> - -- nnoremap <silent> gr <cmd> lua vim.lsp.buf.references()<CR> - -- nnoremap <silent> g0 <cmd> lua vim.lsp.buf.document_symbol()<CR> - -- nnoremap <silent> gW <cmd> lua vim.lsp.buf.workspace_symbol()<CR> - -- nnoremap <silent> ;h <cmd> lua vim.lsp.buf.hover()<CR> - -- nnoremap <silent> ;s <cmd> lua vim.lsp.buf.signature_help()<CR> + -- attach completion + require 'completion'.on_attach(client) + + -- lsp mappings + nnoremap { 'K', function() vim.lsp.buf.hover() end } + nnoremap { '<C-]>', function() vim.lsp.buf.definition() end } + nnoremap { 'gd', function() vim.lsp.buf.definition() end } + nnoremap { 'grr', function() vim.lsp.buf.rename() end } + nnoremap { '<c-h>', function() vim.lsp.buf.signature_help() end } + nnoremap { ']d', function() vim.lsp.diagnostic.goto_next() end } + nnoremap { '[d', function() vim.lsp.diagnostic.goto_prev() end } + + nnoremap { '<leader>f', function() vim.lsp.buf.formatting() end } + + -- nnoremap { 'g0', function() vim.lsp.buf.document_symbol() end } + -- nnoremap { 'gr', function() vim.lsp.buf.references() end } + nnoremap { 'gW', function() vim.lsp.buf.workspace_symbol() end } + nnoremap { 'gD', function() vim.lsp.buf.declaration() end } + nnoremap { 'gT', function() vim.lsp.buf.type_definition() end } + nnoremap { 'gI', function() vim.lsp.buf.implementation() end } + + -- nnoremap <silent> ;s <cmd> lua vim.lsp.buf.signature_help()<CR> + nnoremap { '<leader>d', function() vim.lsp.diagnostic.show_line_diagnostics() end } + + u.augroup2 { + lsp_user = { + {'BufWritePre', '*', 'lua vim.lsp.buf.formatting_sync(nil, 1000)'}, + {'BufWritePre', '*.go', 'lua vim.lsp.buf.code_action({ source = { organizeImports = true } })'}, + {'CursorHold', '*', 'lua vim.lsp.diagnostic.show_line_diagnostics()'}, + } + } end +-- handler overwrites {{{ +-- configure builtin diagnositcs +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = false, + signs = true, + underline = true, + update_in_insert = true, + } +) + +-- overwrite codeAction handler to not ask for confirmation if only a single +-- action is given +vim.lsp.handlers["textDocument/codeAction"] = function(_, _, actions) + if actions == nil or vim.tbl_isempty(actions) then + -- skip printing 'no code actions available' + return + end + + local action_cosen + if #actions == 1 then + action_chosen = actions[1] + else + local option_strings = {"Code Actions:"} + for i, action in ipairs(actions) do + local title = action.title:gsub('\r\n', '\\r\\n') + title = title:gsub('\n', '\\n') + table.insert(option_strings, string.format("%d. %s", i, title)) + end + + local choice = vim.fn.inputlist(option_strings) + if choice < 1 or choice > #actions then + return + end + action_chosen = actions[choice] + end + + if action_chosen.edit or type(action_chosen.command) == "table" then + if action_chosen.edit then + vim.lsp.util.apply_workspace_edit(action_chosen.edit) + end + if type(action_chosen.command) == "table" then + vim.lsp.buf.execute_command(action_chosen.command) + end + else + vim.lsp.buf.execute_command(action_chosen) + end +end +-- }}} + +-- configure signs {{{ +vim.fn.sign_define("LspDiagnosticsSignError", {text="⚡"}) +vim.fn.sign_define("LspDiagnosticsSignWarning", {text="⯈"}) +vim.fn.sign_define("LspDiagnosticsSignInformation", {text="≈"}) +vim.fn.sign_define("LspDiagnosticsSignHint", {text="🞶"}) +-- }}} + -- lsp.ccls.setup{ --- on_attach = my_attach, +-- on_attach = my_attach, -- } lsp.gopls.setup{ - on_attach = my_attach, - root_dir = util.root_pattern('go.mod', '.git'), - -- NOTE: this is done to avoid the gopls warning about being outside gopath - -- message_level = vim.lsp.protocol.MessageType.Error, + on_attach = my_attach, + -- root_dir = util.root_pattern('go.mod', '.git'), + settings = { + gopls = { + -- analyses = { + -- composites = false + -- }, + codelenses = { + test = true, + tidy = true, + }, + gofumpt = true, + } + } } lsp.sumneko_lua.setup{ - on_attach = my_attach; - cmd = { 'lua-language-server' }; - settings = { - Lua = { - runtime = { - version = 'LuaJIT', - }, - diagnostics = { - globals = {'vim'}, - }, - workspace = { - library = { - [vim.fn.expand('$VIMRUNTIME/lua')] = true, - [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, - } - } - } - }, + on_attach = my_attach; + cmd = { 'lua-language-server' }; + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + }, + diagnostics = { + globals = {'vim'}, + }, + workspace = { + library = { + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true, + } + } + } + } } lsp.rust_analyzer.setup{ - on_attach = my_attach, - cmd = { 'env', 'CARGO_TARGET_DIR=/tmp', 'rust-analyzer' }, + on_attach = my_attach, + cmd = { 'env', 'CARGO_TARGET_DIR=/tmp', 'rust-analyzer' }, } + +lsp.efm.setup{ + on_attach = my_attach, + root_dir = util.root_pattern('.git', '.editorconfig'), + init_options = { documentFormatting = true }, + filetypes = { "sh" }, + settings = { + -- rootMarkers = {".git/"}, + languages = { + sh = { + { + lintCommand = 'shellcheck -f gcc -x', + lintSource = 'shellcheck', + lintFormats = { + '%f:%l:%c: %trror: %m', + '%f:%l:%c: %tarning: %m', + '%f:%l:%c: %tote: %m', + }, + formatCommand = 'shfmt -ci -s -bn', + formatStdin = true, + } + } + } + } +} + +lsp.zls.setup{ + on_attach = my_attach +} + +return M diff --git a/.vim/lua/plugins/_markdown.lua b/.vim/lua/plugins/_markdown.lua index c773d50..e02e160 100644 --- a/.vim/lua/plugins/_markdown.lua +++ b/.vim/lua/plugins/_markdown.lua @@ -1,9 +1,12 @@ -g.vim_markdown_folding_disabled = true -g.vim_markdown_math = true -g.vim_markdown_frontmatter = true -g.vim_markdown_json_frontmatter = true -g.vim_markdown_toml_frontmatter = true -g.vim_markdown_folding_level = 2 -g.vim_markdown_strikethrough = true -g.vim_markdown_auto_insert_bullets = true -g.vim_markdown_new_list_item_indent = false +vim.g.vim_markdown_folding_disabled = true +vim.g.vim_markdown_math = true +vim.g.vim_markdown_frontmatter = true +vim.g.vim_markdown_json_frontmatter = true +vim.g.vim_markdown_toml_frontmatter = true +vim.g.vim_markdown_yaml_frontmatter = true +-- vim.g.vim_markdown_folding_level = 2 +vim.g.vim_markdown_strikethrough = true +vim.g.vim_markdown_auto_insert_bullets = true +vim.g.vim_markdown_new_list_item_indent = false +vim.g.vim_markdown_conceal = true +vim.g.vim_markdown_conceal_code_blocks = true diff --git a/.vim/lua/plugins/_neuron.lua b/.vim/lua/plugins/_neuron.lua new file mode 100644 index 0000000..d99a13f --- /dev/null +++ b/.vim/lua/plugins/_neuron.lua @@ -0,0 +1,15 @@ + +local def = require('utils').def + +require('neuron').setup { + virtual_titles = true, + mappings = true, + run = nil, + neuron_dir = "~/.zk", + leader = "gz", +} + +def("NeuronServe", [[ lua require('neuron').rib {address = "127.0.0.1:8200", verbose = true} ]]) +def("NeuronZettels", [[ lua require('neuron/telescope').find_zettels {insert = false} ]]) +def("NeuronZettelsInsert", [[ lua require('neuron/telescope').find_zettels {insert = true} ]]) +def("NeuronTags", [[ lua require('neuron/telescope').find_tags() ]]) diff --git a/.vim/lua/plugins/_telescope.lua b/.vim/lua/plugins/_telescope.lua index d4f9b89..4841862 100644 --- a/.vim/lua/plugins/_telescope.lua +++ b/.vim/lua/plugins/_telescope.lua @@ -1,98 +1,113 @@ -- telescope.nvim et al config -local u = require('utils') +local nnoremap = require('astronauta.keymap').nnoremap local M = {} -- TELESCOPE config -- {{{ require('telescope').setup{ - defaults = { - -- vimgrep_arguments = { - -- 'rg', - -- '--color=never', - -- '--no-heading', - -- '--with-filename', - -- '--line-number', - -- '--column', - -- '--smart-case' - -- }, - - prompt_prefix = ' >', - borderchars = {'─', '│', '─', '│', '┌', '┐', '┘', '└'}, - winblend = 0, - preview_cutoff = 120, - - layout_strategy = 'flex', - - file_previewer = require('telescope.previewers').vim_buffer_cat_new, - grep_previewer = require('telescope.previewers').vim_buffer_vimgrep_new, - qflist_previewer = require('telescope.previewers').vim_buffer_qflist_new, - - extensions = { - fzf_writer = { - use_highlighter = true, - minimum_grep_characters = 4, - shorten_path = true, - } - } - } + defaults = { + initial_mode = 'normal', + prompt_prefix = '> ', + selection_caret = '* ', + + -- copied from dropdown theme + sorting_strategy = 'ascending', + layout_strategy = 'center', + results_title = false, + preview_title = 'P', + preview_cutoff = 1, + width = 0.88, + results_height = 15, + borderchars = { + { '─', '│', '─', '│', '┌', '┐', '┘', '└'}, + prompt = {'─', '│', ' ', '│', '┌', '┐', '│', '│'}, + results = {'─', '│', '─', '│', '├', '┤', '┘', '└'}, + preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└'}, + }, + + file_previewer = require('telescope.previewers').vim_buffer_cat.new, + grep_previewer = require('telescope.previewers').vim_buffer_vimgrep.new, + qflist_previewer = require('telescope.previewers').vim_buffer_qflist.new, + + extensions = { + fzf_writer = { + use_highlighter = true, + minimum_grep_characters = 4, + shorten_path = true, + } + } + } } -- }}} --- LOCAL finders -- {{{ -M.wrap = function(opts) - opts = opts or {} - my_opts = require('telescope.themes').get_dropdown({ width = 110 }) - return vim.tbl_deep_extend("force", my_opts, opts) -end - -M.live_grep = function() - require('telescope').extensions.fzf_writer.staged_grep(M.wrap()) -end - -M.repo_search = function() - require('telescope').extensions.fzf_writer.files(M.wrap({ - previewer = false, - cwd = require('lspconfig.util').root_pattern('.git')(vim.fn.expand('%:p')), - })) -end - -M.wiki = function() - require('telescope').extensions.fzf_writer.files(M.wrap({ - previewer = false, - cwd = '~/wiki/', - })) -end - -M.devel = function() - require('telescope').extensions.fzf_writer.files(M.wrap({ - previewer = false, - cwd = '~/devel/', - })) -end --- }}} - -- MAPPINGS -- {{{ -u.map('n', ';g', "<cmd>lua require('plugins._telescope').live_grep()<cr>") -u.map('n', ';r', "<cmd>lua require('plugins._telescope').repo_search()<cr>") --- u.map('n', ';w', "<cmd>lua require('plugins._telescope').wiki()<cr>") -u.map('n', ';d', "<cmd>lua require('plugins._telescope').devel()<cr>") - -local mapbuiltin = function(key, fn, previewer) - opts = (not previewer and '{ previewer = false }') or '{}' - u.map('n', key, "<cmd>lua require('telescope.builtin')."..fn.."(require('plugins._telescope').wrap("..opts.."))<cr>") -end - -mapbuiltin(';f', 'fd', true) -mapbuiltin(';q', 'quickfix') -mapbuiltin(';l', 'loclist') -mapbuiltin(';b', 'buffers') -mapbuiltin(';t', 'tags') -mapbuiltin(';lr', 'lsp_references') -mapbuiltin(';la', 'lsp_code_actions') -mapbuiltin(';lw', 'lsp_workspace_symbols') -mapbuiltin(';c', 'command_history') +nnoremap { ';g', function() + require('telescope').extensions.fzf_writer.staged_grep() +end } + +nnoremap { ';w', function() + local wr = require('lspconfig.util').root_pattern('.git')(vim.fn.expand('%:p')) + require('telescope').extensions.fzf_writer.files({ + previewer = false, + cwd = wr, + }) +end } + +nnoremap { ';q', function() + local ids = vim.fn.getqflist({winid = 1}) + if ids and not (ids.winid == 0) then + vim.api.nvim_win_close(ids.winid, true) + end + require('telescope.builtin').quickfix() +end } + +nnoremap { ';l', function() + local ids = vim.fn.getloclist(0, {winid = 1}) + if ids and not (ids.winid == 0) then + vim.api.nvim_win_close(ids.winid, true) + end + require('telescope.builtin').loclist() +end } + +nnoremap { ';f', function() + require('telescope.builtin').fd() +end } + +nnoremap { ';b', function() + require('telescope.builtin').buffers() +end } + +nnoremap { ';t', function() + require('telescope.builtin').tags() +end } + +nnoremap { ';h', function() + require('telescope.builtin').command_history() +end } + +nnoremap { ';c', function() + require('telescope.builtin').commands() +end } + +-- LSP stuff + +nnoremap { 'gA', function() + require('telescope.builtin').lsp_code_actions() +end } + +nnoremap { 'gA', function() + require('telescope.builtin').lsp_code_actions() +end } + +nnoremap { 'g0', function() + require('telescope.builtin').lsp_document_symbols() +end } + +nnoremap { 'gr', function() + require('telescope.builtin').lsp_references() +end } -- }}} diff --git a/.vim/lua/plugins/_treesitter.lua b/.vim/lua/plugins/_treesitter.lua index ef24286..c5225bc 100644 --- a/.vim/lua/plugins/_treesitter.lua +++ b/.vim/lua/plugins/_treesitter.lua @@ -1,24 +1,24 @@ require('nvim-treesitter.configs').setup { - ensure_installed = { "c", "c_sharp", "javascript", "lua", "bash" }, - highlight = { - enable = false, - }, - indent = { - enable = true, - }, - refactor = { - navigation = { - enable = true, - keymaps = { - goto_definition = "<c-]>", - }, - }, - smart_rename = { - enable = true, - keymaps = { - smart_rename = "grr", - }, - }, - }, + ensure_installed = { "c", "c_sharp", "lua", "bash" }, + highlight = { + enable = false, + }, + indent = { + enable = true, + }, + refactor = { + navigation = { + enable = true, + keymaps = { + goto_definition = "<c-]>", + }, + }, + smart_rename = { + enable = true, + keymaps = { + smart_rename = "grr", + }, + }, + }, } diff --git a/.vim/lua/plugins/_ultisnips.lua b/.vim/lua/plugins/_ultisnips.lua index f2a6f6e..cd077d2 100644 --- a/.vim/lua/plugins/_ultisnips.lua +++ b/.vim/lua/plugins/_ultisnips.lua @@ -1,4 +1,4 @@ -- vim.g.UltiSnipsListSnippets = "<c-tab>" -vim.g.UltiSnipsExpandTrigger = "<Tab>" +vim.g.UltiSnipsExpandTrigger = vim.g.completion_confirm_key vim.g.UltiSnipsJumpForwardTrigger = "<c-n>" vim.g.UltiSnipsJumpBackwardTrigger = "<c-p>" |