feat: UI improvements
This commit is contained in:
@@ -19,7 +19,20 @@ require("lz.n").load({
|
||||
after = function()
|
||||
require("lazydev").setup({
|
||||
library = {
|
||||
{ words = { "nixCats", "settings" }, path = "nix-info" },
|
||||
{ words = { "nix%-info", "settings" }, path = "nix-info" },
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-navic",
|
||||
after = function()
|
||||
require("nvim-navic").setup({
|
||||
highlight = true,
|
||||
separator = " > ",
|
||||
depth_limit = 5,
|
||||
lsp = {
|
||||
auto_attach = false,
|
||||
},
|
||||
})
|
||||
end,
|
||||
@@ -31,10 +44,75 @@ require("lz.n").load({
|
||||
require("lz.n").trigger_load("lazydev.nvim")
|
||||
end,
|
||||
after = function()
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
|
||||
local telescope_plugins = {
|
||||
"project.nvim",
|
||||
"telescope.nvim",
|
||||
"telescope-fzf-native.nvim",
|
||||
"telescope-ui-select.nvim",
|
||||
}
|
||||
|
||||
local telescope_picker = function(picker)
|
||||
return function()
|
||||
require("lz.n").trigger_load(telescope_plugins)
|
||||
require("telescope.builtin")[picker]()
|
||||
end
|
||||
end
|
||||
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] =
|
||||
vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" })
|
||||
|
||||
local navic_excluded_filetypes = {
|
||||
[""] = true,
|
||||
help = true,
|
||||
minifiles = true,
|
||||
TelescopePrompt = true,
|
||||
Trouble = true,
|
||||
}
|
||||
|
||||
local function navic_enabled(bufnr)
|
||||
return vim.bo[bufnr].buftype == "" and not navic_excluded_filetypes[vim.bo[bufnr].filetype]
|
||||
end
|
||||
|
||||
_G.lux_navic_location = function()
|
||||
local ok, navic = pcall(require, "nvim-navic")
|
||||
if not ok or not navic.is_available() then
|
||||
return ""
|
||||
end
|
||||
|
||||
return navic.get_location()
|
||||
end
|
||||
|
||||
local function update_winbar(winid, bufnr)
|
||||
if not vim.api.nvim_win_is_valid(winid) then
|
||||
return
|
||||
end
|
||||
|
||||
local is_float = vim.api.nvim_win_get_config(winid).relative ~= ""
|
||||
local winbar = ""
|
||||
if not is_float and vim.b[bufnr].lux_navic_attached and navic_enabled(bufnr) then
|
||||
winbar = "%{%v:lua.lux_navic_location()%}"
|
||||
end
|
||||
|
||||
vim.api.nvim_set_option_value("winbar", winbar, { win = winid })
|
||||
end
|
||||
|
||||
local function update_winbars_for_buffer(bufnr)
|
||||
for _, winid in ipairs(vim.fn.win_findbuf(bufnr)) do
|
||||
update_winbar(winid, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter", "WinEnter" }, {
|
||||
group = vim.api.nvim_create_augroup("lux-navic-winbar", { clear = true }),
|
||||
callback = function(args)
|
||||
update_winbar(vim.api.nvim_get_current_win(), args.buf)
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("lux-lsp-attach", { clear = true }),
|
||||
callback = function(args)
|
||||
-- Get the client and buffer from the event arguments [cite: 119]
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
local bufnr = args.buf
|
||||
|
||||
@@ -43,23 +121,30 @@ require("lz.n").load({
|
||||
vim.keymap.set(mode, keys, func, { buffer = bufnr, desc = "LSP: " .. desc })
|
||||
end
|
||||
|
||||
-- Standard LSP functions
|
||||
map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
|
||||
map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" })
|
||||
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
|
||||
map("K", vim.lsp.buf.hover, "Hover Documentation")
|
||||
|
||||
-- Telescope Mappings
|
||||
map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
|
||||
map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
|
||||
map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
|
||||
map("<leader>D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition")
|
||||
map("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
|
||||
map("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
|
||||
map("gd", telescope_picker("lsp_definitions"), "[G]oto [D]efinition")
|
||||
map("gr", telescope_picker("lsp_references"), "[G]oto [R]eferences")
|
||||
map("gI", telescope_picker("lsp_implementations"), "[G]oto [I]mplementation")
|
||||
map("<leader>D", telescope_picker("lsp_type_definitions"), "Type [D]efinition")
|
||||
map("<leader>ds", telescope_picker("lsp_document_symbols"), "[D]ocument [S]ymbols")
|
||||
map("<leader>ws", telescope_picker("lsp_dynamic_workspace_symbols"), "[W]orkspace [S]ymbols")
|
||||
|
||||
if client and client:supports_method("textDocument/documentSymbol", bufnr) and navic_enabled(bufnr) then
|
||||
require("lz.n").trigger_load("nvim-navic")
|
||||
local ok, navic = pcall(require, "nvim-navic")
|
||||
if ok then
|
||||
navic.attach(client, bufnr)
|
||||
vim.b[bufnr].lux_navic_attached = true
|
||||
update_winbars_for_buffer(bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
-- Highlight references (Document Highlight)
|
||||
if client and client:supports_method("textDocument/documentHighlight", bufnr) then
|
||||
local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
|
||||
local highlight_augroup = vim.api.nvim_create_augroup("lux-lsp-highlight", { clear = false })
|
||||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||
buffer = bufnr,
|
||||
group = highlight_augroup,
|
||||
@@ -73,15 +158,14 @@ require("lz.n").load({
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspDetach", {
|
||||
group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
|
||||
group = vim.api.nvim_create_augroup("lux-lsp-detach", { clear = true }),
|
||||
callback = function(event)
|
||||
vim.lsp.buf.clear_references()
|
||||
vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event.buf })
|
||||
vim.api.nvim_clear_autocmds({ group = "lux-lsp-highlight", buffer = event.buf })
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- Inlay Hints
|
||||
if client and client:supports_method("textDocument/inlayHint", bufnr) then
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||
map("<leader>th", function()
|
||||
@@ -91,10 +175,9 @@ require("lz.n").load({
|
||||
end,
|
||||
})
|
||||
|
||||
-- 1. Setup Diagnostics (Visuals)
|
||||
vim.diagnostic.config({
|
||||
severity_sort = true,
|
||||
-- underline = { severity = vim.diagnostic.severity.ERROR },
|
||||
underline = true,
|
||||
signs = {
|
||||
text = {
|
||||
[vim.diagnostic.severity.ERROR] = " ",
|
||||
@@ -103,19 +186,13 @@ require("lz.n").load({
|
||||
[vim.diagnostic.severity.HINT] = " ",
|
||||
},
|
||||
},
|
||||
virtual_text = {
|
||||
virtual_text = false,
|
||||
virtual_lines = {
|
||||
current_line = true,
|
||||
},
|
||||
float = {
|
||||
border = "rounded",
|
||||
source = "if_many",
|
||||
spacing = 4,
|
||||
prefix = "●",
|
||||
format = function(diagnostic)
|
||||
local diagnostic_message = {
|
||||
[vim.diagnostic.severity.ERROR] = diagnostic.message,
|
||||
[vim.diagnostic.severity.WARN] = diagnostic.message,
|
||||
[vim.diagnostic.severity.INFO] = diagnostic.message,
|
||||
[vim.diagnostic.severity.HINT] = diagnostic.message,
|
||||
}
|
||||
return diagnostic_message[diagnostic.severity]
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -124,7 +201,7 @@ require("lz.n").load({
|
||||
Lua = {
|
||||
runtime = { version = "LuaJIT" },
|
||||
signatureHelp = { enabled = true },
|
||||
diagnostics = { globals = { "nixCats", "vim" } },
|
||||
diagnostics = { globals = { "vim" } },
|
||||
telemetry = { enabled = false },
|
||||
completion = { callSnippet = "Replace" },
|
||||
},
|
||||
@@ -134,7 +211,6 @@ require("lz.n").load({
|
||||
|
||||
local settings = require("nix-info").settings
|
||||
|
||||
-- Nix
|
||||
vim.lsp.config("nixd", {
|
||||
settings = {
|
||||
nixd = {
|
||||
@@ -149,19 +225,11 @@ require("lz.n").load({
|
||||
})
|
||||
vim.lsp.enable("nixd")
|
||||
|
||||
-- Dafny
|
||||
vim.lsp.enable("dafny")
|
||||
|
||||
-- TypeScript/JS
|
||||
vim.lsp.enable("ts_ls")
|
||||
|
||||
-- Rust
|
||||
vim.lsp.enable("rust_analyzer")
|
||||
|
||||
-- Python
|
||||
vim.lsp.enable("ty")
|
||||
vim.lsp.enable("ruff")
|
||||
|
||||
vim.lsp.enable("astro")
|
||||
|
||||
vim.lsp.config("tinymist", {
|
||||
@@ -184,6 +252,9 @@ require("lz.n").load({
|
||||
after = function()
|
||||
require("trouble").setup({
|
||||
focus = true,
|
||||
preview = {
|
||||
border = "rounded",
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user