Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/simrat39/inlay-hints.nvim

almost not wip
https://github.com/simrat39/inlay-hints.nvim

Last synced: 3 months ago
JSON representation

almost not wip

Awesome Lists containing this project

README

        

# inlay-hints.nvim

Neovim support for LSP Inlay Hints

## Prerequisites

- `neovim 0.7+`

## Installation

using `packer.nvim`

```lua
use('simrat39/inlay-hints.nvim')
```

Look at the configuration information below to get started.

## Setup

Put this in your init.lua or any lua file that is sourced.

```lua
require("inlay-hints").setup()
```

## Config

Pass a table to the setup call above with your configuration options.

For example:
```lua
require("inlay-hints").setup({
only_current_line = true,

eol = {
right_align = true,
}
})
```
Take a look at all the possible configuration options [here](https://github.com/simrat39/inlay-hints.nvim/blob/main/lua/inlay-hints/config.lua#L3)

## Usage

The plugin hooks itself to the on_attach callback of an LSP Server. Some servers might need extra configuration to enable inlay hints. See the examples below to get started.

### w/ sumneko_lua
```lua
local ih = require("inlay-hints")
local lspconfig = require("lspconfig")

lspconfig.sumneko_lua.setup({
on_attach = function(c, b)
ih.on_attach(c, b)
end,
settings = {
Lua = {
hint = {
enable = true,
},
},
},
})
```

### w/ rust-tools.nvim
```lua
local ih = require("inlay-hints")

require("rust-tools").setup({
tools = {
on_initialized = function()
ih.set_all()
end,
inlay_hints = {
auto = false,
},
},
server = {
on_attach = function(c, b)
ih.on_attach(c, b)
end,
},
})
```

### w/ tsserver
```lua
local ih = require("inlay-hints")
local lspconfig = require("lspconfig")

lspconfig.tsserver.setup({
on_attach = function(c, b)
ih.on_attach(c, b)
end,
settings = {
javascript = {
inlayHints = {
includeInlayEnumMemberValueHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayFunctionParameterTypeHints = true,
includeInlayParameterNameHints = "all", -- 'none' | 'literals' | 'all';
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayVariableTypeHints = true,
},
},
typescript = {
inlayHints = {
includeInlayEnumMemberValueHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayFunctionParameterTypeHints = true,
includeInlayParameterNameHints = "all", -- 'none' | 'literals' | 'all';
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayVariableTypeHints = true,
},
},
},
})
```

### w/ gopls
```lua
local ih = require("inlay-hints")
local lspconfig = require("lspconfig")

lspconfig.gopls.setup({
on_attach = function(c, b)
ih.on_attach(c, b)
end,
settings = {
gopls = {
hints = {
assignVariableTypes = true,
compositeLiteralFields = true,
compositeLiteralTypes = true,
constantValues = true,
functionTypeParameters = true,
parameterNames = true,
rangeVariableTypes = true,
},
},
},
})

```