Comments (9)
I also just wanted to say 'Huge Thanks' to MunifTanjim that this plugin is pretty much achieved all my wishes wanting for a flexible statusline (the LSP status also worked as well with the latest fix). I was using lualine and now I am fully switched. Thanks for the great work!
from nougat.nvim.
Now you can do:
local lsp_servers = nut.lsp.servers.create({
ctx = {
content = {
lua_ls = "LuaLS",
},
hl = {
lua_ls = { fg = "cyan" },
},
},
hl = { bg = "gray", fg = "white" },
sep_left = sep.left_lower_triangle_solid(true),
config = {
content = function(client, item)
return {
content = item.ctx.content[client.name] or client.name,
hl = item.ctx.hl[client.name],
}
end,
sep = " ",
},
suffix = " ",
})
You can format/highlight the display value however you want in the config.content
function. This is the type for it:
If you return nil
that server will not be rendered.
from nougat.nvim.
You need to require
it first. So it'll be like this:
local nut = {
lsp = {
servers = require("nougat.nut.lsp.servers"),
}
}
local lsp_servers = nut.lsp.servers.create({
Or just:
local lsp_servers = require("nougat.nut.lsp.servers").create({
from nougat.nvim.
Nice! Thanks. uhooi/dotfiles@53cc886
from nougat.nvim.
Can you give me a few examples? Which LSP information are you thinking about?
from nougat.nvim.
This setting displays the name and ID of the language server. How's that?
nougat.nvim config
https://github.com/uhooi/dotfiles/blob/12df54582f6a539fae0d30f6dcb88bf8c825a5fe/.config/nvim/lua/plugins/config/nouget.lua
local lsp_util = require('plugins.config.shared.lsp_util')
-- ...
-- lsp info {{{
local lsp_info = (function()
local item = Item {
sep_left = sep.left_half_circle_solid(true),
content = {
Item {
hl = { bg = color.aqua, fg = color.bg },
hidden = function(_, _)
return lsp_util.names == ''
end,
content = lsp_util.names,
},
},
sep_right = sep.right_half_circle_solid(true),
}
return item
end)()
-- }}}
-- tabline {{{
local tal = Bar('tabline')
tal:add_item(lsp_info)
bar_util.set_tabline(tal)
-- }}}
local M = {}
function M:names()
local clients = vim
.iter(vim.lsp.get_clients { bufnr = 0 })
:map(function(client)
if client.name == 'null-ls' then
return ('null-ls[%s](' .. client.id .. ')'):format(table.concat(
vim
.iter(require('null-ls.sources').get_available(vim.bo.filetype))
:map(function(source)
return source.name
end)
:totable(),
', '
))
else
return client.name .. '(' .. client.id .. ')'
end
end)
:totable()
return '' .. ' ' .. table.concat(clients, ', ')
end
return M
from nougat.nvim.
This seems awesome. Do you have more thorough doc on how to integrate the above snippet into the configs (e.g. your example configs are thorough but I don't know how to integrate, sorry for the ignorance).
For now, I just copy&paste the snippet into one of the examples (slanty.lua
) you have and I got this error
local lsp_servers = nut.lsp.servers.create({ <- attempt to index field 'lsp' (a nil value)
from nougat.nvim.
I see. How to config other lsps other than lua_ls? Looks like you had that for example, but I have a few lsps I'd like to add as well. Thanks so much!!
from nougat.nvim.
local lsp_servers = nut.lsp.servers.create({
-- whatever you set here, will be available as `item.ctx`
-- doc: https://github.com/MunifTanjim/nougat.nvim/tree/main/lua/nougat/item#ctx
ctx = {
content = {
lua_ls = "LuaLS",
},
hl = {
lua_ls = { fg = "cyan" },
},
},
hl = { bg = "gray", fg = "white" },
sep_left = sep.left_lower_triangle_solid(true),
config = {
content = function(client, item)
if client.name == "copilot" then
-- if you return nothing, that lsp server will be hidden.
-- so 'copilot' lsp will be hidden
return
end
return {
-- `item.ctx.content` has value for `lua_ls`, so it'll be displayed as `LuaLS`.
-- Other LSP servers will be displayed as default `client.name`
content = item.ctx.content[client.name] or client.name,
-- `item.ctx.hl` has value for `lua_ls`, so it'll be displayed with `cyan` color.
-- Other LSP servers will have default/no colors.
hl = item.ctx.hl[client.name],
}
end,
sep = " ",
},
suffix = " ",
})
As you see, it's very flexible. You can do whatever you want.
If you want to give custom name (e.g. LuaLS
) for other LSP servers, you can add them in ctx.content
table. If you want to change highlight for them, set that in ctx.hl
.
You can also use ctx
for hiding lsp servers too, for example:
local lsp_servers = nut.lsp.servers.create({
ctx = {
hidden = {
copilot = true,
},
},
config = {
content = function(client, item)
if item.ctx.hidden[item.name] then
return
end
-- do other stuffs
end,
},
})
Hope that helps.
from nougat.nvim.
Related Issues (14)
- Support breakpoints for responsive content
- Item Priority
- Stack trace for type mismatch HOT 4
- Use colorscheme patterns HOT 2
- [Wishlist] Nut for Nougat HOT 2
- Statusbar doesn't show on session restore. HOT 7
- :hammer_and_wrench: Show clock HOT 2
- :hammer_and_wrench: How to configure `lsp.servers` content? HOT 2
- quest: possibility to change colors for the modes and diagnostics? HOT 3
- quest: get the number of lines of a file? HOT 1
- Add filetype icon for filetype component HOT 7
- Support vim-gitbranch/vim-gitgutter as git branch/status source HOT 5
- Color API Design: the `red` `yellow` API name seems confusing HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nougat.nvim.