{"id":13896066,"url":"https://github.com/RishabhRD/lspactions","last_synced_at":"2025-07-17T12:30:39.378Z","repository":{"id":45099828,"uuid":"406048809","full_name":"RishabhRD/lspactions","owner":"RishabhRD","description":"handlers for required lsp actions","archived":false,"fork":false,"pushed_at":"2022-05-15T08:39:12.000Z","size":34,"stargazers_count":54,"open_issues_count":1,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-08-07T18:37:50.566Z","etag":null,"topics":["lsp","lua","neovim","nvim","vim"],"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}},"created_at":"2021-09-13T16:30:55.000Z","updated_at":"2024-07-01T06:09:22.000Z","dependencies_parsed_at":"2022-09-16T13:46:03.471Z","dependency_job_id":null,"html_url":"https://github.com/RishabhRD/lspactions","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%2Flspactions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RishabhRD%2Flspactions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RishabhRD%2Flspactions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RishabhRD%2Flspactions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RishabhRD","download_url":"https://codeload.github.com/RishabhRD/lspactions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226260601,"owners_count":17596494,"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":["lsp","lua","neovim","nvim","vim"],"created_at":"2024-08-06T18:02:38.444Z","updated_at":"2024-11-25T01:31:02.508Z","avatar_url":"https://github.com/RishabhRD.png","language":"Lua","funding_links":[],"categories":["Lua"],"sub_categories":[],"readme":"# lspactions\n\nlspactions provide handlers for various lsp actions. lspactions also provide\nutility functions for exposing UI for other components. lspactions targets to\nbe highly extensible and customizable. It uses floating windows for handlers\n**if it really improves workflow**(I am biased) otherwise try to provide\nsimilar (but highy customizable) handlers to nvim's default handlers.\n\n**lspactions require neovim nightly release**\n\nCurrent lspactions handlers:\n- codeaction (floating win)\n- rename (floating win + robust prompt)\n- references (customizable quickfix)\n- definition (customizable quickfix)\n- declaration (customizable quickfix)\n- implementation (customizable quickfix)\n- diagnostics (layer on vim.diagnostics)\n\nCurrent UI exposing functions:\n- select (floating win selector for items)\n- input (floating prompt input)\n\ndocument\\_symbols and workspace\\_symbols are good with telescope and hence\nis not targetted. If you feel there is some better way to do the same, feel\nfree to make a PR.\n\n## Dependencies\n\n- [plenary.nvim](https://github.com/nvim-lua/plenary.nvim)\n- [popup.nvim](https://github.com/nvim-lua/popup.nvim)\n\n## Installation\n\n```vim\nPlug 'nvim-lua/plenary.nvim'\nPlug 'nvim-lua/popup.nvim'\nPlug 'RishabhRD/lspactions'\n```\n\n## Current UI exposing functions\n\n### select\n\nFloating menu for user to pick a single item from a collection of entries.\n\n```lua\nvim.ui.select = require'lspactions'.select\n```\n\nIt has mostly same spec as vim.ui.select. Please refer ``:h vim.ui.select``\n\nAdditional to ``vim.ui.select``, select suppports following additional options:\n\n- opts.keymaps : table\n\nSample table(Also default):\n```lua\n  opts.keymaps = {\n    quit = {\n      n = {\n        \"q\",\n        \"\u003cEsc\u003e\",\n      },\n    },\n    exec = {\n      n = {\n        \"\u003cCR\u003e\",\n      },\n    },\n  }\n```\n\n\n\n### input\n\nFloating menu prompt for user to input some text. The prompt doesn't have any neovim\nprompt buffer problems.\n\n```lua\nvim.ui.input = require'lspactions'.input\n```\n\nIt has mostly same spec as vim.ui.input. Please refer ``:h vim.ui.input``\nAddition to the options provided in ``vim.ui.input`` it supports following\nadditional options:\n\n- opts.keymaps : table\n\nSample table(Also default):\n```lua\n  opts.keymaps = {\n      quit = {\n        i = {\n          \"\u003cC-c\u003e\",\n        },\n        n = {\n          \"q\",\n          \"\u003cEsc\u003e\",\n        },\n      },\n      exec = {\n        i = {\n          \"\u003cCR\u003e\",\n        },\n        n = {\n          \"\u003cCR\u003e\",\n        },\n      },\n  }\n```\n\nquit contains mappings for keys where we don't accept the current input and just want\nto close the buffer.\n\nexec contains mappings for keys where we accept the current input and have to act upon\nit.\n\n\n``vim.ui.input = require'lspactions'.input`` for renaming functionality.\nIf user doesn't wish to use floating buffer input globally, then user can use\nlspactions rename module.\n\n## Current handlers\n\n### rename\n\n```vim\nnnoremap \u003cleader\u003ear :lua require'lspactions'.rename()\u003cCR\u003e\n```\n\nIt doesn't have any of problem that neovim's prompt buffer have that means\nprompt has old name as initial text and user can seamlessly edit the text\ninside prompt.\n\n![](https://user-images.githubusercontent.com/26287448/133168403-35d5c6e0-16ad-44ee-9d2e-e3d056016746.gif)\n\nCustomization:\n```lua\nrequire'lspactions'.rename(nil, {\n    input = vim.ui.input, -- NOT lspactions default\n    keymap = \u003ckeymap_table\u003e -- sample shown in input section\n})\n```\ninput function has same specifications as ``vim.ui.input``. It describes how\nuser would input new name for the node.\n\n### codeaction\n\n```lua\nvim.lsp.handlers[\"textDocument/codeAction\"] = require'lspactions'.codeaction\nvim.cmd [[ nnoremap \u003cleader\u003eaf :lua require'lspactions'.code_action()\u003cCR\u003e ]]\nvim.cmd [[ nnoremap \u003cleader\u003eaf :lua require'lspactions'.range_code_action()\u003cCR\u003e ]]\n```\n\nFloating menu for codeaction. You can scroll same as normal vim movements.\nPress enter to select the action. Or like: press 4 to select action 4.\n\nCustomization:\n```lua\nvim.lsp.handlers[\"textDocument/codeAction\"] = vim.lsp.with(require'lspactions'.codeaction, {\n    transform = function(result) return result end,\n    ui_select = vim.ui.select, -- NOT lspactions default\n})\n```\n\nui\\_select has same specifications as ``vim.ui.select`` has. It describes how\nuser would be prompted to select a code action from a list of codeactions.\nSo providing ``vim.ui.select`` would provide selection menu as vim's default\nselection menu. And not overriding this option would give a floating list as\nselection menu.\n\ntransform function accepts a function that takes result returned from\nlsp-server as argument, and return\na new result by making some transformation on it. The transformation can be\nanything like sorting, etc.\n\n![](https://user-images.githubusercontent.com/26287448/133169313-1c2118e3-48b8-47bc-b457-6e3a2ac9bca1.gif)\n\n### references\n```lua\nvim.lsp.handlers[\"textDocument/references\"] = require'lspactions'.references\nvim.cmd [[ nnoremap \u003cleader\u003eaf :lua vim.lsp.buf.references()\u003cCR\u003e ]]\n```\n\nSimilar to lsp references, but way more customizable.\n\nCustomization:\n```lua\nvim.lsp.handlers[\"textDocument/references\"] = vim.lsp.with(require'lspactions'.references, {\n  open_list = true,\n  jump_to_result = true,\n  jump_to_list = false,\n  loclist = false,\n  always_qf = false,\n  transform = function(result) return result end\n})\n```\n\n- loclist: use location list instead\n- open\\_list: to open quickfix/loclist list or not\n- jump\\_to\\_result: jump to first result of operation in current window\n- jump\\_to\\_list: make quickfix/loclist list current window\n- always\\_qf: open quickfix/loclist even if there is only one result\n- transform: a function that accepts result returned from lsp-server, do\nsome transformation on it(maybe like sorting) and return the new result.\n\n### definition\n```lua\nvim.lsp.handlers[\"textDocument/definition\"] = require'lspactions'.definition\nvim.cmd [[ nnoremap \u003cleader\u003eaf :lua vim.lsp.buf.definition()\u003cCR\u003e ]]\n```\n\nSimilar to lsp definition, but way more customizable.\n\nCustomization:\n```lua\nvim.lsp.handlers[\"textDocument/definition\"] = vim.lsp.with(require'lspactions'.definition, {\n  open_list = true,\n  jump_to_result = true,\n  jump_to_list = false,\n  loclist = false,\n  always_qf = false,\n  transform = function(result) return result end\n})\n```\n\n- loclist: use location list instead\n- open\\_list: to open quickfix/loclist list or not\n- jump\\_to\\_result: jump to first result of operation in current window\n- jump\\_to\\_list: make quickfix/loclist list current window\n- always\\_qf: open quickfix/loclist even if there is only one result\n- transform: a function that accepts result returned from lsp-server, do\nsome transformation on it(maybe like sorting) and return the new result.\n\n### declaration\n```lua\nvim.lsp.handlers[\"textDocument/declaration\"] = require'lspactions'.declaration\nvim.cmd [[ nnoremap \u003cleader\u003eaf :lua vim.lsp.buf.declaration()\u003cCR\u003e ]]\n```\n\nSimilar to lsp declaration, but way more customizable.\n\nCustomization:\n```lua\nvim.lsp.handlers[\"textDocument/declaration\"] = vim.lsp.with(require'lspactions'.declaration, {\n  open_list = true,\n  jump_to_result = true,\n  jump_to_list = false,\n  loclist = false,\n  always_qf = false,\n  transform = function(result) return result end\n})\n```\n\n- loclist: use location list instead\n- open\\_list: to open quickfix/loclist list or not\n- jump\\_to\\_result: jump to first result of operation in current window\n- jump\\_to\\_list: make quickfix/loclist list current window\n- always\\_qf: open quickfix/loclist even if there is only one result\n- transform: a function that accepts result returned from lsp-server, do\nsome transformation on it(maybe like sorting) and return the new result.\n\n### implementation\n```lua\nvim.lsp.handlers[\"textDocument/implementation\"] = require'lspactions'.implementation\nvim.cmd [[ nnoremap \u003cleader\u003eaf :lua vim.lsp.buf.implementation()\u003cCR\u003e ]]\n```\n\nSimilar to lsp implementation, but way more customizable.\n\nCustomization:\n```lua\nvim.lsp.handlers[\"textDocument/implementation\"] = vim.lsp.with(require'lspactions'.implementation, {\n  open_list = true,\n  jump_to_result = true,\n  jump_to_list = false,\n  loclist = false,\n  always_qf = false,\n  transform = function(result) return result end\n})\n```\n\n- loclist: use location list instead\n- open\\_list: to open quickfix/loclist list or not\n- jump\\_to\\_result: jump to first result of operation in current window\n- jump\\_to\\_list: make quickfix/loclist list current window\n- always\\_qf: open quickfix/loclist even if there is only one result\n- transform: a function that accepts result returned from lsp-server, do\nsome transformation on it(maybe like sorting) and return the new result.\n\n### diagnostics\n\nAll the parameters presented in code of this section are optional.\n\n```lua\nlocal diag = require'lspactions'.diagnostics\n```\n\n#### show\\_position\\_diagnostics\n\n```lua\ndiag.show_position_diagnostics(opts, bufnr, position)\n```\n  - opts : table with fields\n    - severity : string with possible values: {ERROR, WARN, INFO, HINT}\n\n#### show\\_line\\_diagnostics\n\n```lua\ndiag.show_line_diagnostics(opts, bufnr, position)\n```\n  - opts : table with fields\n    - severity : string with possible values: {ERROR, WARN, INFO, HINT}\n\n#### goto\\_next\n\n```lua\ndiag.goto_next(opts)\n```\n  - opts : table with fields\n    - severity : string with possible values: {ERROR, WARN, INFO, HINT}\n    - wrap : bool (default true) Whether to loop around file or not\n    - float: bool (default true) Whether to open floating window after jumping to next diagnostic\n\n\n#### goto\\_prev\n\n```lua\ndiag.goto_prev(opts)\n```\n  - opts : table with fields\n    - severity : string with possible values: {ERROR, WARN, INFO, HINT}\n    - wrap : bool (default true) Whether to loop around file or not\n    - float: bool (default true) Whether to open floating window after jumping to previous diagnostic\n\n\n#### set\\_qflist\n\n```lua\ndiag.set_qflist(opts)\n```\n  - opts : table with fields\n    - severity : string with possible values: {ERROR, WARN, INFO, HINT}\n    - client\\_id : Which client to diagnostics to display\n#### set\\_loclist\n\n```lua\ndiag.set_loclist(opts)\n```\n  - opts : table with fields\n    - severity : string with possible values: {ERROR, WARN, INFO, HINT}\n    - client\\_id : Which client to diagnostics to display\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRishabhRD%2Flspactions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRishabhRD%2Flspactions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRishabhRD%2Flspactions/lists"}