https://github.com/chrisgrieser/nvim-lsp-endhints
Display LSP inlay hints at the end of the line, rather than within the line.
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: researchgate.net -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.5%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Display LSP inlay hints at the end of the line, rather than within the line.
Basic Info
Statistics
- Stars: 197
- Watchers: 1
- Forks: 6
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
nvim-lsp-endhints 🪧
Minimal plugin that displays LSP inlay hints at the end of the line, rather than within the line.
Color scheme: nightfox.nvim, dawnfox variant
Table of Contents
Installation
Requirements
- nvim 0.10+
- LSP client supports inlay hints (textDocument/inlayHint)
- Inlay hints enabled in the config of the LSP
```lua -- lazy.nvim { "chrisgrieser/nvim-lsp-endhints", event = "LspAttach", opts = {}, -- required, even if empty },
-- packer use { "chrisgrieser/nvim-lsp-endhints", config = function() require("lsp-endhints").setup() -- required, even if empty end, } ```
Configuration
The .setup() call is required.
lua
-- default settings
require("lsp-endhints").setup {
icons = {
type = " ",
parameter = " ",
offspec = " ", -- hint kind not defined in official LSP spec
unknown = " ", -- hint kind is nil
},
label = {
truncateAtChars = 20,
padding = 1,
marginLeft = 0,
sameKindSeparator = ", ",
},
extmark = {
priority = 50,
},
autoEnableHints = true,
}
The hints use the default highlight group LspInlayHint.
Usage
By default, the plugin automatically enables inlay hints when attaching to an LSP, there is nothing to do other than loading the plugin.
All regular inlay hint functions like vim.lsp.inlay_hint.enable() work the
same as before. Use them as described in the Neovim
documentation
to enable/disable/toggle hints manually.
You can switch between displaying inlay hints at the end of the line (this plugin)
and within the line (Neovim default) by using the enable, disable and toggle
functions:
```lua -- inlay hints will show at the end of the line (default) require("lsp-endhints").enable()
-- inlay hints will show as if the plugin was not installed require("lsp-endhints").disable()
-- toggle between the two require("lsp-endhints").toggle() ```
Background
- The LSP specification stipulates that inlay hints have a fixed position in the line, which Neovim core follows.
- However, for many people, hints being positioned within the line disturbs the flow of vim motions. This is particularly troublesome for languages with long type hints, such as TypeScript.
- nvim-inlayhint did pretty
much the same thing for nvim < 0.10, but it is archived by now. Other than
being maintained,
nvim-lsp-endhintsjust overrides thetextDocument/inlayHinthandler introduced in nvim 0.10, resulting in a much simpler and more maintainable implementation (~250 LoC instead of ~1000 LoC).
FAQ
How to display hints only for the current line?
That is not supported by the plugin. However, it only takes a small snippet to implement it yourself. (Note that the linked snippet is not compatible with this plugin.)
Compatibility with other inlay hints plugins
Since this plugin overrides the nvim handler for "textDocument/inlayHint",
other plugins that interact with inlay hints may be incompatible with it, and
there is likely little there can be done about it.
However, if the other plugin is using specific commands related to inlay hints
rather than permanently displaying them like nvim-lsp-endhints, you can
temporarily disable endhints, trigger the other plugin, and then re-enable
endhints. Binding that to a custom function should allow you to use the other
plugin without issues then.
How to enable inlay hints for a language?
[!NOTE] Not all LSPs support inlay hints. The following list is not exhaustive, there are more LSPs that support inlay hints. Please refer to your LSP's documentation.
```lua -- lua-ls require("lspconfig").lua_ls.setup { settings = { Lua = { hint = { enable = true }, }, }, }
-- tsserver local inlayHints = { includeInlayParameterNameHints = "all", includeInlayParameterNameHintsWhenArgumentMatchesName = false, includeInlayFunctionParameterTypeHints = true, includeInlayVariableTypeHints = true, includeInlayVariableTypeHintsWhenTypeMatchesName = false, includeInlayPropertyDeclarationTypeHints = true, includeInlayFunctionLikeReturnTypeHints = true, includeInlayEnumMemberValueHints = true, } require("lspconfig").tsserver.setup { settings = { typescript = { inlayHints = inlayHints, }, javascript = { inlayHints = inlayHints, }, }, }
-- gopls require("lspconfig").gopls.setup { settings = { hints = { rangeVariableTypes = true, parameterNames = true, constantValues = true, assignVariableTypes = true, compositeLiteralFields = true, compositeLiteralTypes = true, functionTypeParameters = true, }, }, }
-- clangd require("lspconfig").clangd.setup { settings = { clangd = { InlayHints = { Designators = true, Enabled = true, ParameterNames = true, DeducedTypes = true, }, fallbackFlags = { "-std=c++20" }, }, }, } ```
About the author
In my day job, I am a sociologist studying the social mechanisms underlying the digital economy. For my PhD project, I investigate the governance of the app economy and how software ecosystems manage the tension between innovation and compatibility. If you are interested in this subject, feel free to get in touch.
Owner
- Name: Chris Grieser
- Login: chrisgrieser
- Kind: user
- Location: Berlin, Germany
- Company: Technical University of Berlin
- Website: https://chris-grieser.de/
- Repositories: 189
- Profile: https://github.com/chrisgrieser
Researcher in sociology & software developer
GitHub Events
Total
- Issues event: 10
- Watch event: 89
- Delete event: 4
- Issue comment event: 13
- Push event: 32
- Pull request event: 10
- Fork event: 3
- Create event: 3
Last Year
- Issues event: 10
- Watch event: 89
- Delete event: 4
- Issue comment event: 13
- Push event: 32
- Pull request event: 10
- Fork event: 3
- Create event: 3
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Chris Grieser | 7****r | 95 |
| dependabot[bot] | 4****] | 2 |
| vxpm | v****m@g****m | 1 |
| Mateus Melchiades | m****e@d****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 9 months ago
All Time
- Total issues: 11
- Total pull requests: 6
- Average time to close issues: about 4 hours
- Average time to close pull requests: 2 days
- Total issue authors: 11
- Total pull request authors: 4
- Average comments per issue: 2.27
- Average comments per pull request: 1.67
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 3
Past Year
- Issues: 11
- Pull requests: 6
- Average time to close issues: about 4 hours
- Average time to close pull requests: 2 days
- Issue authors: 11
- Pull request authors: 4
- Average comments per issue: 2.27
- Average comments per pull request: 1.67
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 3
Top Authors
Issue Authors
- Wppopqpu (1)
- julien-h (1)
- FelipeLema (1)
- vxpm (1)
- Davidyz (1)
- al-ce (1)
- ford-prefect (1)
- samyarkd (1)
- druskus20 (1)
- catgoose (1)
- vunhatchuong (1)
Pull Request Authors
- dependabot[bot] (7)
- Tdback (2)
- vxpm (2)
- matbme (2)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- actions/checkout v4 composite
- stevearc/nvim-typecheck-action v2 composite
- actions/checkout v4 composite
- kdheepak/panvimdoc main composite
- stefanzweifel/git-auto-commit-action v4 composite
- amannn/action-semantic-pull-request v5 composite
- actions/stale v8 composite
- JohnnyMorganz/stylua-action v4 composite
- actions/checkout v4 composite
- stefanzweifel/git-auto-commit-action v4 composite