{"id":13409173,"url":"https://github.com/RishabhRD/nvim-lsputils","last_synced_at":"2025-03-14T14:31:01.145Z","repository":{"id":39404549,"uuid":"296410292","full_name":"RishabhRD/nvim-lsputils","owner":"RishabhRD","description":"Better defaults for nvim-lsp actions","archived":false,"fork":false,"pushed_at":"2023-10-28T16:35:30.000Z","size":130,"stargazers_count":451,"open_issues_count":16,"forks_count":20,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-07-31T20:34:44.813Z","etag":null,"topics":["fuzzy-search","lsp","neovim","neovim-plugin"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RishabhRD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-09-17T18:28:54.000Z","updated_at":"2024-07-31T10:07:57.000Z","dependencies_parsed_at":"2024-01-23T07:49:30.785Z","dependency_job_id":null,"html_url":"https://github.com/RishabhRD/nvim-lsputils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RishabhRD%2Fnvim-lsputils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RishabhRD%2Fnvim-lsputils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RishabhRD%2Fnvim-lsputils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RishabhRD%2Fnvim-lsputils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RishabhRD","download_url":"https://codeload.github.com/RishabhRD/nvim-lsputils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243593300,"owners_count":20316163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fuzzy-search","lsp","neovim","neovim-plugin"],"created_at":"2024-07-30T20:00:58.540Z","updated_at":"2025-03-14T14:31:00.832Z","avatar_url":"https://github.com/RishabhRD.png","language":"Lua","funding_links":[],"categories":["LSP","Lua"],"sub_categories":["(requires Neovim 0.5)"],"readme":"# nvim-lsputils\n\nNeovim built-in LSP client implementation is so lightweight and awesome.\nHowever, default settings for actions like go-to-definition, code-quickfix, etc\nmay not seem user friendly for many users. But neovim LSP client is highly\nextensible with lua. This plugin focuses on making such LSP actions highly user\nfriendly.\n\n## Features\n\n- Floating popup for code actions\n- Preview window for references\n- Preview window for definition, declaration, type-definition, implementation\n- Preview window for document symbol and workspace symbol\n- Fuzzy finding of symbols, references, defintion and codeActions [optional]\n- \u003cC-t\u003e, \u003cC-v\u003e, \u003cC-x\u003e opens tabs, vertical split and horizontal split for\n  location and symbol actions\n\n## Demo\n\n### Code Action:\n![](https://user-images.githubusercontent.com/26287448/98861852-f7b7bd00-248b-11eb-8c11-fd37ab5d45d7.gif)\n\n\n### References:\n![](https://user-images.githubusercontent.com/26287448/98860407-9ee72500-2489-11eb-8b61-4ca7cb3f78ee.gif)\n\n### Custom theming (See below for more details)\n![](https://user-images.githubusercontent.com/26287448/98858320-6abe3500-2486-11eb-8795-a8d1bb8dbecc.gif)\n\n### Fuzzy search:\n![](https://user-images.githubusercontent.com/26287448/100378731-abe34700-3039-11eb-98e6-151007b49d5a.gif)\n\n\n## Future goals\n\n- LspSearch command to search symbol over workspace and list it in a window.\n\n**Fuzzy finding feature is optional for the time being. This is because\nfuzzy engine of popfix is still in developement. However, it usually doesn't\ncrash and work as expected. For using it read custom options section. \nFor the code snippet read sample theming section.**\n\n## Prerequisite\n\n- Neovim nightly\n\n## Installation\n\nThis plugin utilizes RishabhRD/popfix plugin for managing underlying popups\nand previews.\nIt can be installed with any plugin manager. For example with vim-plug:\n\n\tPlug 'RishabhRD/popfix'\n\tPlug 'RishabhRD/nvim-lsputils'\n\n## Setup\n\nAdd following to init.vim lua chunk as:\n\n\tlua \u003c\u003cEOF\n    if vim.fn.has('nvim-0.5.1') == 1 then\n        vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler\n        vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler\n        vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler\n        vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler\n        vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler\n        vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler\n        vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler\n        vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler\n    else\n        local bufnr = vim.api.nvim_buf_get_number(0)\n\n        vim.lsp.handlers['textDocument/codeAction'] = function(_, _, actions)\n            require('lsputil.codeAction').code_action_handler(nil, actions, nil, nil, nil)\n        end\n\n        vim.lsp.handlers['textDocument/references'] = function(_, _, result)\n            require('lsputil.locations').references_handler(nil, result, { bufnr = bufnr }, nil)\n        end\n\n        vim.lsp.handlers['textDocument/definition'] = function(_, method, result)\n            require('lsputil.locations').definition_handler(nil, result, { bufnr = bufnr, method = method }, nil)\n        end\n\n        vim.lsp.handlers['textDocument/declaration'] = function(_, method, result)\n            require('lsputil.locations').declaration_handler(nil, result, { bufnr = bufnr, method = method }, nil)\n        end\n\n        vim.lsp.handlers['textDocument/typeDefinition'] = function(_, method, result)\n            require('lsputil.locations').typeDefinition_handler(nil, result, { bufnr = bufnr, method = method }, nil)\n        end\n\n        vim.lsp.handlers['textDocument/implementation'] = function(_, method, result)\n            require('lsputil.locations').implementation_handler(nil, result, { bufnr = bufnr, method = method }, nil)\n        end\n\n        vim.lsp.handlers['textDocument/documentSymbol'] = function(_, _, result, _, bufn)\n            require('lsputil.symbols').document_handler(nil, result, { bufnr = bufn }, nil)\n        end\n\n        vim.lsp.handlers['textDocument/symbol'] = function(_, _, result, _, bufn)\n            require('lsputil.symbols').workspace_handler(nil, result, { bufnr = bufn }, nil)\n        end\n    end\n\tEOF\n\n## Default keymaps\n\n### For codeaction\n\n**In normal mode:**\n\n|Key     |Action                                     |\n|:------:|-------------------------------------------|\n|\\\u003cCR\\\u003e  |Applies the codeaction                     |\n|\\\u003cEsc\\\u003e |Quits the menu without applying codeaction |\n|q       |Quits the menu without applying codeaction |\n|j       |Selects next item                          |\n|k       |Selects previous item                      |\n|\\\u003cDown\\\u003e|Selects next item                          |\n|\\\u003cUp\\\u003e  |Selects previous item                      |\n\n\n**In insert mode(Fuzzy search mode):**\n\n|Key     |Action                                     |\n|:------:|-------------------------------------------|\n|\\\u003cCR\\\u003e  |Applies the codeaction                     |\n|\\\u003cC-c\\\u003e |Quits the menu without applying codeaction |\n|\\\u003cC-n\\\u003e |Selects next item                          |\n|\\\u003cC-p\\\u003e |Selects previous item                      |\n|\\\u003cDown\\\u003e|Selects next item                          |\n|\\\u003cUp\\\u003e  |Selects previous item                      |\n\n### For symbols, references, and defintions\n\n(document symbols + workspace symbols + references + defintions)\n\n**In normal mode:**\n\n|Key     |Action                                     |\n|:------:|-------------------------------------------|\n|\\\u003cCR\\\u003e  |Jump to location in same window            |\n|\\\u003cC-v\\\u003e |Jump to location in a vertical split       |\n|\\\u003cC-x\\\u003e |Jump to location in a horizontal split     |\n|\\\u003cC-t\\\u003e |Jump to location in a new tab              |\n|\\\u003cEsc\\\u003e |Quits the menu without jumping to location |\n|q       |Quits the menu without jumping to location |\n|j       |Selects next item                          |\n|k       |Selects previous item                      |\n|\\\u003cDown\\\u003e|Selects next item                          |\n|\\\u003cUp\\\u003e  |Selects previous item                      |\n\n**In insert mode(Fuzzy search mode):**\n\n|Key     |Action                                     |\n|:------:|-------------------------------------------|\n|\\\u003cCR\\\u003e  |Jump to location in same window            |\n|\\\u003cC-v\\\u003e |Jump to location in a vertical split       |\n|\\\u003cC-x\\\u003e |Jump to location in a horizontal split     |\n|\\\u003cC-t\\\u003e |Jump to location in a new tab              |\n|\\\u003cC-c\\\u003e |Quits the menu without jumping to location |\n|\\\u003cC-n\\\u003e |Selects next item                          |\n|\\\u003cC-p\\\u003e |Selects previous item                      |\n|\\\u003cDown\\\u003e|Selects next item                          |\n|\\\u003cUp\\\u003e  |Selects previous item                      |\n  \n## Custom Filetypes\n\nnvim-lsputils export some custom filetypes for their created buffer.\nThis enables users to do customization for nvim-lsputil buffers.\n\nCustom filetypes are:\n\n- For codeaction:\n\n    - lsputil_codeaction_list (Represents codeaction list)\n    - lsputil_codeaction_prompt (Represents codeaction prompt) (If enabled)\n\n- For symbols (workspace and document symbols):\n\n    - lsputil_symbols_list (Represents symbols list)\n    - lsputil_symbols_preview (Represents symbols preview)\n    - lsputil_symbols_prompt (Represents symbols prompt)\n\n- For locations (definition, declaration, references, implementation):\n\n    - lsputil_locations_list (Represents locations list)\n    - lsputil_locations_preview (Represents locations preview)\n    - lsputil_locations_prompt (Represents locations prompt)\n\n## Custom Options\n\n**NOTE: EACH attribute of custom opts is optional. If not provided, a suitable\ndefault is used in place of it.**\n\nnvim-lsputils provides 3 global variables:\n\n- lsp_utils_location_opts\n- lsp_utils_symbols_opts\n- lsp_utils_codeaction_opts\n\nThese 3 variables are supposed to have vimscript dictionary values (Lua tables)\n\nlsp_utils_location_opts defines options for:\n\n- definition handler\n- references handler\n- declaration handler\n- implementation handler\n- type_definition hander\n\nlsp_utils_symbols_opts defines options for:\n\n- workspace symbol handler\n- files symbols handler\n\nlsp_utils_codeaction_opts defines options for:\n\n- code_action handler\n\nlsp_utils_location_opts and lsp_utils_symbols_opts takes following key-value pairs:\n\n- height (integer) (Defines height of window)\n\tif value is 0 then a suitable default height is provided. (Specially for\n\t\teditor mode)\n- width (integer) (Defines width of window)\n- mode (string)\n\t- split (for split previews (default))\n\t- editor (for floating previews)\n- list (vimscript dictionary / Lua tables) Accepts following key/value pairs:\n\t- border (boolean) (borders in floating mode)\n\t- numbering (boolean) (vim window numbering active or not)\n\t- title (boolean) (title for window)\n\t- border_chars (vimscript dictionary/ Lua table) (border characters for list)\n\t\tSample border_chars example:\n\t\t```\n\t\tborder_chars = {\n\t\t\tTOP_LEFT = '┌',\n\t\t\tTOP_RIGHT = '┐',\n\t\t\tMID_HORIZONTAL = '─',\n\t\t\tMID_VERTICAL = '│',\n\t\t\tBOTTOM_LEFT = '└',\n\t\t\tBOTTOM_RIGHT = '┘',\n\t\t}\n\t\t```\n\t\tIf any of shown key of border_chars is missing then a space character\n\t\tis used instead of it.\n- preview (vimscript dictionary / Lua tables) Accepts following key/value pairs:\n\t- border (boolean) (borders in floating mode)\n\t- numbering (boolean) (vim window numbering active or not)\n\t- title (string) (title for window)\n\t- border_chars (vimscript dictionary/ Lua table) (border characters for preview window)\n\t\tSample border_chars example:\n\t\t```\n\t\tborder_chars = {\n\t\t\tTOP_LEFT = '┌',\n\t\t\tTOP_RIGHT = '┐',\n\t\t\tMID_HORIZONTAL = '─',\n\t\t\tMID_VERTICAL = '│',\n\t\t\tBOTTOM_LEFT = '└',\n\t\t\tBOTTOM_RIGHT = '┘',\n\t\t}\n\t\tIf any of shown key of border_chars is missing then a space character\n\t\tis used instead of it.\n- keymaps (vimscript dictionary / Lua tables) Additional keymaps.\n\tSee https://github.com/RishabhRD/popfix to read about keymaps documentation.\n\nlsp_utils_codeaction_opts takes following key-value pairs:\n\n- height (integer) (Defines height of window)\n\tif value is 0 then a suitable default height is provided. (Specially for\n\t\teditor mode)\n- width (integer) (Defines width of window)\n- mode (string)\n\t- split (for split previews (default))\n\t- editor (for floating previews)\n- list (vimscript dictionary / Lua tables) Accepts following key/value pairs:\n\t- border (boolean) (borders in floating mode)\n\t- numbering (boolean) (vim window numbering active or not)\n\t- title (string) (title for window)\n\t- border_chars (vimscript dictionary/ Lua table) (border characters for list)\n\t\tSample border_chars example:\n\t\t```\n\t\tborder_chars = {\n\t\t\tTOP_LEFT = '┌',\n\t\t\tTOP_RIGHT = '┐',\n\t\t\tMID_HORIZONTAL = '─',\n\t\t\tMID_VERTICAL = '│',\n\t\t\tBOTTOM_LEFT = '└',\n\t\t\tBOTTOM_RIGHT = '┘',\n\t\t}\n\t\t```\n\t\tIf any of shown key of border_chars is missing then a space character\n\t\tis used instead of it.\n- prompt (table) (optional and may break)\n\t- border (boolean) (borders in floating mode)\n\t- numbering (boolean) (vim window numbering active or not)\n\t- border_chars (vimscript dictionary/ Lua table) (border characters for list)\n\t\tSample border_chars example:\n\t\t```\n\t\tborder_chars = {\n\t\t\tTOP_LEFT = '┌',\n\t\t\tTOP_RIGHT = '┐',\n\t\t\tMID_HORIZONTAL = '─',\n\t\t\tMID_VERTICAL = '│',\n\t\t\tBOTTOM_LEFT = '└',\n\t\t\tBOTTOM_RIGHT = '┘',\n\t\t}\n\t\t```\n\t\tIf any of shown key of border_chars is missing then a space character\n\t\tis used instead of it.\n\nSee https://github.com/RishabhRD/popfix for more documentation of options.\n\nThese options helps to get better theme that suits your need.\n\n### Sample themeing with lua\n\n```\nlocal border_chars = {\n\tTOP_LEFT = '┌',\n\tTOP_RIGHT = '┐',\n\tMID_HORIZONTAL = '─',\n\tMID_VERTICAL = '│',\n\tBOTTOM_LEFT = '└',\n\tBOTTOM_RIGHT = '┘',\n}\nvim.g.lsp_utils_location_opts = {\n\theight = 24,\n\tmode = 'editor',\n\tpreview = {\n\t\ttitle = 'Location Preview',\n\t\tborder = true,\n\t\tborder_chars = border_chars\n\t},\n\tkeymaps = {\n\t\tn = {\n\t\t\t['\u003cC-n\u003e'] = 'j',\n\t\t\t['\u003cC-p\u003e'] = 'k',\n\t\t}\n\t}\n}\nvim.g.lsp_utils_symbols_opts = {\n\theight = 24,\n\tmode = 'editor',\n\tpreview = {\n\t\ttitle = 'Symbols Preview',\n\t\tborder = true,\n\t\tborder_chars = border_chars\n\t},\n\tprompt = {},\n}\n```\n\n**Symbols would have fuzzy find features with these configuration**\n\n## Advanced configuration\n\nnvim-lsputils provides some extension in handler function definition so that\nit can be integrated with some other lsp plugins easily.\n\nCurrently codeaction supports this extended defintion. Codeaction handler signature\nis something like:\n\n```lua\ncode_action_handler(_, _, actions, _, _, _, customSelectionHandler)\n```\n\n``customSelectionHandler`` is not defined by standard docs. However, nvim-lsputils\nprovide it for easy extension and use with other plugins. ``customSelectionHandler`` is expected to be a function\nthat accepts the selection action(from all codeactions) as parameter. If provided to the function,\nthe function executes this customSelectionHandler with selected action instead\nof applying codeaction directly.\n\nA simple ``customSelectionHandler`` can look like:\n```lua\nlocal function customSelectionHandler(selectedAction)\n  print(\"Action selected: \", selectedAction)\nend\n```\n\n\nOne simple example is integration with [nvim-jdtls](https://github.com/mfussenegger/nvim-jdtls).\n\n```lua\nlocal jdtls_ui = require'jdtls.ui'\nfunction jdtls_ui.pick_one_async(items, _, _, cb)\n  require'lsputil.codeAction'.code_action_handler(nil, nil, items, nil, nil, nil, cb)\nend\n```\n\nThis code snippet modifies the nvim-jdtls UI to make use of nvim-lsputils UI.\nWith this code snippet, nvim-lsputils would provide the UI but the action would\nbe decided by the functin parameter cb.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRishabhRD%2Fnvim-lsputils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRishabhRD%2Fnvim-lsputils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRishabhRD%2Fnvim-lsputils/lists"}