diff --git a/lazy-lock.json b/lazy-lock.json index a9991cf..8e31f28 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -15,9 +15,11 @@ "friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" }, "fzf-lua": { "branch": "main", "commit": "c1de84f9c9cb227d2bef65643625f1fb8207bf8f" }, "gitsigns.nvim": { "branch": "main", "commit": "ff01d34daaed72f271a8ffa088a7e839a60c640f" }, + "goto-preview": { "branch": "main", "commit": "b428db4d2a5b7c06e149a020e31b2121fbf57a67" }, "gruvbox.nvim": { "branch": "main", "commit": "477c62493c82684ed510c4f70eaf83802e398898" }, "indent-blankline.nvim": { "branch": "master", "commit": "0fe34b4c1b926e106d105d3ae88ef6cbf6743572" }, "lazy.nvim": { "branch": "main", "commit": "1c16e4236f0937e8955865a0e5e046c7dafbc4b5" }, + "lsp-lens.nvim": { "branch": "main", "commit": "296e0d33dddba1a1de9b69143f189cb994111c5a" }, "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "e7b64c11035aa924f87385b72145e0ccf68a7e0a" }, "mason.nvim": { "branch": "main", "commit": "cd7835b15f5a4204fc37e0aa739347472121a54c" }, diff --git a/lua/config/gotopreview.lua b/lua/config/gotopreview.lua new file mode 100644 index 0000000..b52f21f --- /dev/null +++ b/lua/config/gotopreview.lua @@ -0,0 +1,21 @@ +require("goto-preview").setup({ + width = 120, -- Width of the floating window + height = 15, -- Height of the floating window + border = { "↖", "─", "┐", "│", "┘", "─", "└", "│" }, -- Border characters of the floating window + default_mappings = false, -- Bind default mappings + debug = false, -- Print debug information + opacity = nil, -- 0-100 opacity level of the floating window where 100 is fully transparent. + resizing_mappings = false, -- Binds arrow keys to resizing the floating window. + post_open_hook = nil, -- A function taking two arguments, a buffer and a window to be ran as a hook. + post_close_hook = nil, -- A function taking two arguments, a buffer and a window to be ran as a hook. + references = { -- Configure the telescope UI for slowing the references cycling window. + telescope = require("telescope.themes").get_dropdown({ hide_preview = false }), + }, + -- These two configs can also be passed down to the goto-preview definition and implementation calls for one off "peak" functionality. + focus_on_open = true, -- Focus the floating window when opening it. + dismiss_on_move = false, -- Dismiss the floating window when moving the cursor. + force_close = true, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close + bufhidden = "wipe", -- the bufhidden option to set on the floating window. See :h bufhidden + stack_floating_preview_windows = true, -- Whether to nest floating windows + preview_window_title = { enable = true, position = "left" }, -- Whether to set the preview window title as the filename +}) diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 2c134f7..6ab8de7 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -1,3 +1,9 @@ -- Keymaps are automatically loaded on the VeryLazy event -- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- Add any additional keymaps here +-- nnoremap gpd lua require('goto-preview').goto_preview_definition() +-- nnoremap gpt lua require('goto-preview').goto_preview_type_definition() +-- nnoremap gpi lua require('goto-preview').goto_preview_implementation() +-- nnoremap gpD lua require('goto-preview').goto_preview_declaration() +-- nnoremap gP lua require('goto-preview').close_all_win() +-- nnoremap gpr lua require('goto-preview').goto_preview_references() diff --git a/lua/config/lsplens.lua b/lua/config/lsplens.lua new file mode 100644 index 0000000..cee9c7b --- /dev/null +++ b/lua/config/lsplens.lua @@ -0,0 +1,12 @@ +require("lsp-lens").setup({ + enable = true, + include_declaration = false, -- Reference include declaration + sections = { -- Enable / Disable specific request + definition = false, + references = true, + implements = true, + }, + ignore_filetype = { + "prisma", + }, +}) diff --git a/lua/config/neogit.lua b/lua/config/neogit.lua new file mode 100644 index 0000000..a49cc5c --- /dev/null +++ b/lua/config/neogit.lua @@ -0,0 +1,219 @@ +local neogit = require("neogit") + +neogit.setup({ + -- Hides the hints at the top of the status buffer + disable_hint = false, + -- Disables changing the buffer highlights based on where the cursor is. + disable_context_highlighting = false, + -- Disables signs for sections/items/hunks + disable_signs = false, + -- Do not ask to confirm the commit - just do it when the buffer is closed. + disable_commit_confirmation = false, + -- Changes what mode the Commit Editor starts in. `true` will leave nvim in normal mode, `false` will change nvim to + -- insert mode, and `"auto"` will change nvim to insert mode IF the commit message is empty, otherwise leaving it in + -- normal mode. + disable_insert_on_commit = true, + -- When enabled, will watch the `.git/` directory for changes and refresh the status buffer in response to filesystem + -- events. + filewatcher = { + interval = 1000, + enabled = true, + }, + -- Used to generate URL's for branch popup action "pull request". + git_services = { + ["github.com"] = "https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1", + ["bitbucket.org"] = "https://bitbucket.org/${owner}/${repository}/pull-requests/new?source=${branch_name}&t=1", + ["gitlab.com"] = "https://gitlab.com/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}", + }, + -- Allows a different telescope sorter. Defaults to 'fuzzy_with_index_bias'. The example below will use the native fzf + -- sorter instead. By default, this function returns `nil`. + telescope_sorter = function() + return require("telescope").extensions.fzf.native_fzf_sorter() + end, + -- Persist the values of switches/options within and across sessions + remember_settings = true, + -- Scope persisted settings on a per-project basis + use_per_project_settings = true, + -- Table of settings to never persist. Uses format "Filetype--cli-value" + ignored_settings = { + "NeogitPushPopup--force-with-lease", + "NeogitPushPopup--force", + "NeogitPullPopup--rebase", + "NeogitCommitPopup--allow-empty", + "NeogitRevertPopup--no-edit", + }, + -- Neogit refreshes its internal state after specific events, which can be expensive depending on the repository size. + -- Disabling `auto_refresh` will make it so you have to manually refresh the status after you open it. + auto_refresh = true, + -- Value used for `--sort` option for `git branch` command + -- By default, branches will be sorted by commit date descending + -- Flag description: https://git-scm.com/docs/git-branch#Documentation/git-branch.txt---sortltkeygt + -- Sorting keys: https://git-scm.com/docs/git-for-each-ref#_options + sort_branches = "-committerdate", + -- Change the default way of opening neogit + kind = "tab", + -- Disable line numbers and relative line numbers + disable_line_numbers = true, + -- The time after which an output console is shown for slow running commands + console_timeout = 2000, + -- Automatically show console if a command takes more than console_timeout milliseconds + auto_show_console = true, + status = { + recent_commit_count = 10, + }, + commit_editor = { + kind = "split", + }, + commit_select_view = { + kind = "tab", + }, + commit_view = { + kind = "vsplit", + verify_commit = os.execute("which gpg") == 0, -- Can be set to true or false, otherwise we try to find the binary + }, + log_view = { + kind = "tab", + }, + rebase_editor = { + kind = "split", + }, + reflog_view = { + kind = "tab", + }, + merge_editor = { + kind = "split", + }, + tag_editor = { + kind = "split", + }, + preview_buffer = { + kind = "split", + }, + popup = { + kind = "split", + }, + signs = { + -- { CLOSED, OPENED } + hunk = { "", "" }, + item = { ">", "v" }, + section = { ">", "v" }, + }, + -- Each Integration is auto-detected through plugin presence, however, it can be disabled by setting to `false` + integrations = { + -- If enabled, use telescope for menu selection rather than vim.ui.select. + -- Allows multi-select and some things that vim.ui.select doesn't. + telescope = nil, + -- Neogit only provides inline diffs. If you want a more traditional way to look at diffs, you can use `diffview`. + -- The diffview integration enables the diff popup. + -- + -- Requires you to have `sindrets/diffview.nvim` installed. + diffview = nil, + + -- If enabled, uses fzf-lua for menu selection. If the telescope integration + -- is also selected then telescope is used instead + -- Requires you to have `ibhagwan/fzf-lua` installed. + fzf_lua = nil, + }, + sections = { + -- Reverting/Cherry Picking + sequencer = { + folded = false, + hidden = false, + }, + untracked = { + folded = false, + hidden = false, + }, + unstaged = { + folded = false, + hidden = false, + }, + staged = { + folded = false, + hidden = false, + }, + stashes = { + folded = true, + hidden = false, + }, + unpulled_upstream = { + folded = true, + hidden = false, + }, + unmerged_upstream = { + folded = false, + hidden = false, + }, + unpulled_pushRemote = { + folded = true, + hidden = false, + }, + unmerged_pushRemote = { + folded = false, + hidden = false, + }, + recent = { + folded = true, + hidden = false, + }, + rebase = { + folded = true, + hidden = false, + }, + }, + mappings = { + finder = { + [""] = "Select", + [""] = "Close", + [""] = "Close", + [""] = "Next", + [""] = "Previous", + [""] = "Next", + [""] = "Previous", + [""] = "MultiselectToggleNext", + [""] = "MultiselectTogglePrevious", + [""] = "NOP", + }, + -- Setting any of these to `false` will disable the mapping. + status = { + ["q"] = "Close", + ["I"] = "InitRepo", + ["1"] = "Depth1", + ["2"] = "Depth2", + ["3"] = "Depth3", + ["4"] = "Depth4", + [""] = "Toggle", + ["x"] = "Discard", + ["s"] = "Stage", + ["S"] = "StageUnstaged", + [""] = "StageAll", + ["u"] = "Unstage", + ["U"] = "UnstageStaged", + ["d"] = "DiffAtFile", + ["$"] = "CommandHistory", + ["#"] = "Console", + [""] = "RefreshBuffer", + [""] = "GoToFile", + [""] = "VSplitOpen", + [""] = "SplitOpen", + [""] = "TabOpen", + ["?"] = "HelpPopup", + ["D"] = "DiffPopup", + ["p"] = "PullPopup", + ["r"] = "RebasePopup", + ["m"] = "MergePopup", + ["P"] = "PushPopup", + ["c"] = "CommitPopup", + ["l"] = "LogPopup", + ["v"] = "RevertPopup", + ["Z"] = "StashPopup", + ["A"] = "CherryPickPopup", + ["b"] = "BranchPopup", + ["f"] = "FetchPopup", + ["X"] = "ResetPopup", + ["M"] = "RemotePopup", + ["{"] = "GoToPreviousHunkHeader", + ["}"] = "GoToNextHunkHeader", + }, + }, +}) diff --git a/lua/config/symbolusage b/lua/config/symbolusage new file mode 100644 index 0000000..c6c1dc5 --- /dev/null +++ b/lua/config/symbolusage @@ -0,0 +1,55 @@ +-- local SymbolKind = vim.lsp.protocol.SymbolKind +-- +-- ---@type UserOpts +-- local default_opts = { +-- ---@type table `nvim_set_hl`-like options for highlight virtual text +-- hl = { link = "Comment" }, +-- ---@type lsp.SymbolKind[] Symbol kinds what need to be count (see `lsp.SymbolKind`) +-- kinds = { SymbolKind.Function, SymbolKind.Method }, +-- ---Additional filter for kinds. Recommended use in the filetypes override table. +-- ---fiterKind: function(data: { symbol:table, parent:table, bufnr:integer }): boolean +-- ---`symbol` and `parent` is an item from `textDocument/documentSymbol` request +-- ---See: #filter-kinds +-- ---@type table +-- kinds_filter = {}, +-- ---@type 'above'|'end_of_line'|'textwidth' above by default +-- vt_position = "above", +-- ---Text to display when request is pending. If `false`, extmark will not be +-- ---created until the request is finished. Recommended to use with `above` +-- ---vt_position to avoid "jumping lines". +-- ---@type string|table|false +-- request_pending_text = "loading...", +-- ---The function can return a string to which the highlighting group from `opts.hl` is applied. +-- ---Alternatively, it can return a table of tuples of the form `{ { text, hl_group }, ... }`` - in this case the specified groups will be applied. +-- ---See `#format-text-examples` +-- ---@type function(symbol: Symbol): string|table Symbol{ definition = integer|nil, implementation = integer|nil, references = integer|nil } +-- -- text_format = function(symbol) end, +-- references = { enabled = true, include_declaration = false }, +-- definition = { enabled = true }, +-- implementation = { enabled = true }, +-- ---@type UserOpts[] See default overridings in `lua/symbol-usage/langs.lua` +-- -- filetypes = {}, +-- } +-- local function text_format(symbol) +-- local fragments = {} +-- +-- if symbol.references then +-- local usage = symbol.references <= 1 and "usage" or "usages" +-- local num = symbol.references == 0 and "no" or symbol.references +-- table.insert(fragments, ("%s %s"):format(num, usage)) +-- end +-- +-- if symbol.definition then +-- table.insert(fragments, symbol.definition .. " defs") +-- end +-- +-- if symbol.implementation then +-- table.insert(fragments, symbol.implementation .. " impls") +-- end +-- +-- return table.concat(fragments, ", ") +-- end +-- +-- require("symbol-usage").setup({ +-- text_format = text_format, +-- }) diff --git a/lua/plugins/gotopreview.lua b/lua/plugins/gotopreview.lua new file mode 100644 index 0000000..a3fb692 --- /dev/null +++ b/lua/plugins/gotopreview.lua @@ -0,0 +1,6 @@ +return { + "rmagatti/goto-preview", + config = function() + require("goto-preview").setup({}) + end, +} diff --git a/lua/plugins/lsplens.lua b/lua/plugins/lsplens.lua new file mode 100644 index 0000000..2027b17 --- /dev/null +++ b/lua/plugins/lsplens.lua @@ -0,0 +1,6 @@ +return { + "VidocqH/lsp-lens.nvim", + config = function() + require("lsp-lens").setup() + end, +} diff --git a/lua/plugins/symbolusage b/lua/plugins/symbolusage new file mode 100644 index 0000000..2665c46 --- /dev/null +++ b/lua/plugins/symbolusage @@ -0,0 +1,8 @@ +-- return { +-- +-- "Wansmer/symbol-usage.nvim", +-- event = "BufReadPre", -- need run before LspAttach if you use nvim 0.9. On 0.10 use 'LspAttach' +-- config = function() +-- require("symbol-usage").setup() +-- end, +-- }