neovim: adds lsp keybinds
f2343112f82555b756adbae15de94e6c10b85d26
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: 4c9230aebed6
bugabingas dorkfiles
f2343112f82555b756adbae15de94e6c10b85d26
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+536 / −159 text lines · 1 binary (striped old/new sizes in 64-byte units, not churn) · lines and sizes scale separately
+2 / −1 text lines
new file mode 100644+5 / −0 text lines
+2 / −6 text lines
new file mode 100644+1 / −0 text lines
+7 / −3 text lines
+3 / −1 text lines
+6 / −0 text lines
+1 / −0 text lines
+6 / −6 text lines
+8 / −3 text lines
+93 / −2 text lines
config.capabilities = require('bugabinga.completion').get_lsp_capabilities(config.capabilities) -- the following are already set by default -- but i will remap them anyways for consistency map.normal { description = 'code action', category = 'lsp', keys = 'gra', command = vim.lsp.buf.code_action, } map.normal { description = 'implementation', category = 'lsp', keys = 'gri', command = vim.lsp.buf.implementation, } map.normal { description = 'rename', category = 'lsp', keys = 'grn', command = vim.lsp.buf.rename, } map.normal { description = 'references', category = 'lsp', keys = 'grr', command = vim.lsp.buf.references, } -- create mappings for rest of lsp functions in the default style: gr prefix map.normal { description = 'definition', category = 'lsp', keys = 'grd', command = vim.lsp.buf.definition, } map.normal { description = 'list workspace folders', category = 'lsp', keys = 'grwl', command = vim.lsp.buf.list_workspace_folders, } map.normal { description = 'add workspace folder', category = 'lsp', keys = 'grwa', command = vim.lsp.buf.add_workspace_folder, } map.normal { description = 'remove workspace folder', category = 'lsp', keys = 'grwr', command = vim.lsp.buf.remove_workspace_folder, } map.normal { description = 'incoming calls', category = 'lsp', keys = 'grc', command = vim.lsp.buf.incoming_calls, } map.normal { description = 'outgoing calls', category = 'lsp', keys = 'grC', command = vim.lsp.buf.outgoing_calls, } map.normal { description = 'type definition', category = 'lsp', keys = 'grt', command = vim.lsp.buf.type_definition, } map.normal { description = 'type hierarchy (subtypes)', category = 'lsp', keys = 'grh', command = function() vim.lsp.buf.typehierarchy 'subtypes' end, } map.normal { description = 'type hierarchy (supertypes)', category = 'lsp', keys = 'grH', command = function() vim.lsp.buf.typehierarchy 'supertypes' end, } map.insert { description = 'signature help', category = 'lsp', keys = '<c-space>', command = vim.lsp.buf.signature_help, }+0 / −1 text lines
+36 / −14 text lines
local set_group_properties = function ( self, properties )local set_group_properties = function(self, properties)_.FloatBorderCorner { fg = ui_accent, bg = _.Normal.bg }-- NeoTreeGitAdded File name when the git status is added._.NeoTreeGitAdded = _.DiffAdd-- NeoTreeGitConflict File name when the git status is conflict._.NeoTreeGitConflict = _.DiffChange-- NeoTreeGitDeleted File name when the git status is deleted._.NeoTreeGitDeleted = _.DiffDelete-- NeoTreeGitIgnored File name when the git status is ignored.-- NeoTreeGitModified File name when the git status is modified._.NeoTreeGitModified = _.DiffChange-- NeoTreeGitUnstaged Used for git unstaged symbol._.NeoTreeGitUnstaged = _.DiffChange-- NeoTreeGitUntracked File name when the git status is untracked._.NeoTreeGitUntracked = _.DiffChange-- NeoTreeGitStaged Used for git staged symbol._.NeoTreeGitStaged = _.DiffText_.MiniHipatternsFixme { fg = ui_normal, bg = _.DiagnosticError.fg }_.MiniHipatternsHack { fg = ui_normal, bg = _.DiagnosticWarn.fg }_.MiniHipatternsTodo { fg = ui_normal, bg = _.DiagnosticHint.fg }_.MiniHipatternsNote { fg = ui_normal, bg = _.DiagnosticInfo.fg }+13 / −2 text lines
puk.defer 'mini.operators' (function(operators) operators.setup { -- Evaluate text and replace with output evaluate = { prefix = '<leader>o=' }, -- Exchange text regions exchange = { prefix = '<leader>ox' }, -- Multiply (duplicate) text multiply = { prefix = '<leader>om' }, -- Replace text with register replace = { prefix = '<leader>or' }, -- Sort text sort = { prefix = '<leader>os' } }+0 / −40 text lines
-- Stolen from mini.misc plugin at https://github.com/echasnovski/mini.misclocal restore_cursor = function() -- Stop if not a normal buffer if vim.bo.buftype ~= '' then return end -- Stop if filetype is ignored if vim.tbl_contains(ignored.filetypes, vim.bo.filetype) then return end -- Stop if line is already specified (like during start with `nvim file +num`) local cursor_line = vim.api.nvim_win_get_cursor(0)[1] if cursor_line > 1 then return end -- Stop if can't restore proper line for some reason local mark_line = vim.api.nvim_buf_get_mark(0, [["]])[1] local n_lines = vim.api.nvim_buf_line_count(0) if not (1 <= mark_line and mark_line <= n_lines) then return end -- Restore cursor and open just enough folds vim.cmd [[normal! g`"zv]] -- Center window vim.cmd 'normal! zz'end-- Create autocommand which runs once on `FileType` for every new bufferauto 'restore_cursor_position_setup' { description = 'Setup function to restore cursor position', events = 'BufReadPre', command = function(data) auto 'restore_cursor_position' { description = 'Restores last known cursor position when opening a buffer.', events = 'FileType', buffer = data.buf, once = true, command = restore_cursor, } end,}+54 / −37 text lines
-- if vim.fn.executable 'nu' then-- -- integrate Nushell with nvim-- vim.opt.shell = 'nu'-- -- flags for nu:-- -- * `--stdin` redirect all input to -c-- -- * `--no-newline` do not append `\n` to stdout-- -- * `--commands` execute a command-- vim.opt.shellcmdflag = '--stdin --no-newline --commands'-- -- string to be used to put the output of shell commands in a temp file-- -- 1. when 'shelltemp' is `true`-- -- 2. in the `diff-mode` (`nvim -d file1 file2`) when `diffopt` is set-- -- to use an external diff command: `set diffopt-=internal`-- vim.opt.shellredir = 'out+err> "%s"'-- -- string to be used with `:make` command to:-- -- 1. save the stderr of `makeprg` in the temp file which Neovim reads using `errorformat` to populate the `quickfix` buffer-- -- 2. show the stdout, stderr on the screen-- -- NOTE: `ansi strip` removes all ansi coloring from nushell errors-- vim.opt.shellpipe =-- '| complete | get stderr stdout | str join (char nl) | ansi strip | tee { save --force --raw "%s" }'-- -- WARN: disable the usage of temp files for shell commands-- -- because Nu doesn't support `input redirection` which Neovim uses to send buffer content to a command:-- -- `{shell_command} < {temp_file_with_selected_buffer_content}`-- -- When set to `false` the stdin pipe will be used instead.-- -- NOTE: some info about `shelltemp`: https://github.com/neovim/neovim/issues/1008-- vim.opt.shelltemp = false-- vim.opt.shellxquote = ''-- vim.opt.shellxescape = ''-- vim.opt.shellquote = ''-- endif vim.fn.executable 'nu' then -- setting the shell too early can block startup vim.schedule(function() -- integrate Nushell with nvim vim.opt.shell = 'nu' -- flags for nu: -- * `--stdin` redirect all input to -c -- * `--no-newline` do not append `\n` to stdout -- * `--commands` execute a command vim.opt.shellcmdflag = '--stdin --no-newline --commands' -- string to be used to put the output of shell commands in a temp file -- 1. when 'shelltemp' is `true` -- 2. in the `diff-mode` (`nvim -d file1 file2`) when `diffopt` is set -- to use an external diff command: `set diffopt-=internal` vim.opt.shellredir = 'out+err> "%s"' -- string to be used with `:make` command to: -- 1. save the stderr of `makeprg` in the temp file which Neovim reads using `errorformat` to populate the `quickfix` buffer -- 2. show the stdout, stderr on the screen -- NOTE: `ansi strip` removes all ansi coloring from nushell errors vim.opt.shellpipe = '| complete | get stderr stdout | str join (char nl) | ansi strip | tee { save --force --raw "%s" }' -- WARN: disable the usage of temp files for shell commands -- because Nu doesn't support `input redirection` which Neovim uses to send buffer content to a command: -- `{shell_command} < {temp_file_with_selected_buffer_content}` -- When set to `false` the stdin pipe will be used instead. -- NOTE: some info about `shelltemp`: https://github.com/neovim/neovim/issues/1008 vim.opt.shelltemp = false vim.opt.shellxquote = '' vim.opt.shellxescape = '' vim.opt.shellquote = '' end)endvim.opt.wildoptions = 'fuzzy,pum'vim.g.border_style = 'single'vim.g.border_style = { { "🬷", 'FloatBorderCorner' }, -- top left { "▔", 'FloatBorder' }, -- top { "🬲", 'FloatBorderCorner' }, -- top right { "🮈", 'FloatBorder' }, -- right { "🬕", 'FloatBorderCorner' }, -- bottom right { "▁", 'FloatBorder' }, -- bottom { "🬨", 'FloatBorderCorner' }, -- bottom left { "▍", 'FloatBorder' }, -- left}require 'bugabinga.options.menus'new file mode 100644+10 / −0 text lines
-- disable friendly beginner message in context menuvim.cmd.aunmenu [[PopUp.How-to\ disable\ mouse]]vim.iter(pairs(vim.lsp.buf)) :filter(function(_, action) return type(action) == 'function' end) :each(function(name, _) vim.cmd.anoremenu('PopUp.' .. name .. ' <cmd>lua vim.lsp.buf.' .. name .. '()<cr>') end)new file mode 100644+5 / −0 text lines
+10 / −1 text lines
splitjoin.setup()+78 / −14 text lines
local puk = require 'std.puk'local user_command = require 'std.user_command'puk.defer 'neoterm' (function(neoterm) neoterm.setup { clear_on_run = true, -- Run clear command before user specified commands position = 'center', -- Position of the terminal window: fullscreen (0), top (1), right (2), bottom (3), left (4), center (5) (string or integer value) noinsert = false, -- Disable entering insert mode when opening the neoterm window width = 0.69, -- Width of the terminal window (percentage, ratio, or range between 0-1) height = 0.69, -- Height of the terminal window (percentage, ratio, or range between 0-1)} map.normal.terminal { description = 'Toggle terminal', category = 'terminal', keys = '<leader>tt', command = neoterm.toggle,local open_float = function(options) options = options or {} local max_width = vim.o.columns local max_height = vim.o.lines local size = options.size or 0.88 local width = options.width or math.floor(max_width * size) local height = options.height or math.floor(max_height * size) local center_col = math.floor((max_width - width) / 2) local center_row = math.floor((max_height - height) / 2) local buffer_created = false local create_buffer = function() buffer_created = true return vim.api.nvim_create_buf(false, true) end local buffer = vim.api.nvim_buf_is_valid(options.buffer) and options.buffer or create_buffer() local window_settings = { relative = "editor", width = width, height = height, col = center_col, row = center_row, style = 'minimal', border = options.border or vim.g.border_style,end) local window = vim.api.nvim_open_win(buffer, true, window_settings) if buffer_created then vim.cmd.terminal('nu --login') end vim.cmd.startinsert() local buffer_options = { buflisted = false, } for buffer_option, value in pairs(buffer_options) do vim.api.nvim_set_option_value(buffer_option, value, { buf = buffer, }) end local window_options = { winbar = '', } for window_option, value in pairs(window_options) do vim.api.nvim_set_option_value(window_option, value, { win = window, }) end return { buffer = buffer, window = window, }endlocal toggle_terminal = function() if vim.api.nvim_win_is_valid(state.float.window) then vim.api.nvim_win_hide(state.float.window) else state.float = open_float(state.float) endenduser_command.Terminal 'Toggle Terminal in floating window' (toggle_terminal)map.normal.terminal { description = 'Toggle terminal', category = 'terminal', keys = '<F7>', command = toggle_terminal,}map.terminal { description = 'Enter normal mode', category = 'terminal', keys = '<esc><esc>', command = '<c-\\><c-n>'}new file mode 100644+35 / −0 text lines
local puk = require 'std.puk'local map = require 'std.map'puk.defer 'neo-tree' (function(neotree) vim.cmd.packadd 'plenary' vim.cmd.packadd 'nui' neotree.setup { close_if_last_window = true, -- Close Neo-tree if it is the last window left in the tab popup_border_style = vim.g.border_style, filesystem = { filtered_items = { visible = true, }, follow_current_file = { enabled = true, -- This will find and focus the file in the active buffer every time -- the current file is changed while the tree is open. }, group_empty_dirs = true, -- when true, empty folders will be grouped together hijack_netrw_behavior = "disabled", -- netrw disabled, opening a directory opens neo-tree -- in whatever position is specified in window.position -- "open_current", -- netrw disabled, opening a directory opens within the -- window like netrw would, regardless of window.position -- "disabled", -- netrw left alone, neo-tree does not handle opening dirs use_libuv_file_watcher = true, -- This will use the OS level file watchers to detect changes -- instead of relying on nvim autocmd events. }, } map.normal { description = "Toggle tree view", keys = "<leader>e", category = "tree", command = '<cmd>Neotree reveal<cr>', }end)new file mode 100644+72 / −0 text lines
local buffer_options = { bufhidden = 'hide', modifiable = false, filetype = 'markdown', -- Alternative: use help ft}local window_border = 'shadow'local window_options = { winblend = 42,}local open = function() -- create unlisted scratch buffer local buffer = vim.api.nvim_create_buf(false, true) -- must be done, before buffer is set to unmodifiable vim.api.nvim_buf_set_lines(buffer, 0, 1, false, { '# Cheat Sheet', '', '> Remember the following keymaps!' -- TODO: where to get this from? from std.map }) for name, value in pairs(buffer_options) do vim.api.nvim_set_option_value(name, value, { scope = 'local', buf = buffer, }) end local half_height = math.ceil(vim.o.lines * 0.5) local half_width = math.ceil(vim.o.columns * 0.5) local window = vim.api.nvim_open_win(buffer, true, { border = window_border, relative = 'editor', style = 'minimal', height = half_height, width = half_width, row = math.ceil(half_height * 0.5), col = math.ceil(half_width * 0.5), }) for name, value in pairs(window_options) do vim.api.nvim_set_option_value(name, value, { scope = 'local', win = window, }) end local close = function() vim.api.nvim_win_hide(window) end local buffer_keymaps = { { 'n', '<esc>', close }, { 'n', 'q', close }, } for _, map in ipairs(buffer_keymaps) do vim.keymap.set(map[1], map[2], map[3]) endendreturn setmetatable( { open = open, }, { })+2 / −0 text lines
+10 / −1 text lines
let exclusions = [**/tests/**, **/scripts/**, **/fixtures/**, **/target/release/deps/**]+53 / −21 text lines
], [ plenary, github, "nvim-lua/plenary.nvim", master, "2d9b06177a975543726ce5c73fca176cedbffe9d", null ], [ nui, github, "MunifTanjim/nui.nvim", main, "53e907ffe5eedebdca1cd503b00aa8692068ca46", null ], [ neo-tree, github, "nvim-neo-tree/neo-tree.nvim", main, "d7266e467de1adbaf775cbd4bff9b68842e27386", null ], [ friendly-snippets, github, rafamadriz/friendly-snippets, main, "efff286dd74c22f731cdec26a70b46e5b203c619", nullnew file mode 100644+9 / −0 text lines
+9 / −0 text lines
Binary size (old → new): 1967 → 2095 bytes.
+1 / −1 text lines
+1 / −1 text lines
+4 / −4 text lines