Compare commits

...

2 Commits

Author SHA1 Message Date
kyasuda
ab82ecb001 update noice 2025-08-21 16:57:51 -07:00
kyasuda
9fa25eaf5a update to use conform 2025-08-21 13:51:34 -07:00
7 changed files with 137 additions and 135 deletions

View File

@@ -4,9 +4,7 @@ require("core.keymaps")
-- require("core.lsp-notifications")
require("utils.extensions")
require("utils.telescope_extra").setup()
require("utils.git_paste").setup({
telescope_key = "<leader>pg",
})
require("utils.git_paste").setup({ telescope_key = "<leader>pg" })
require("utils.treesitter.parsers.hyprlang")
require("utils.hyprland.lsp")
-- vim.notify = function(msg, level, opts)

View File

@@ -17,7 +17,7 @@ end
local spinner_frames = { "", "", "", "", "", "", "", "" }
local function update_spinner(client_id, token)
local function update_spinner(client_id, token, title)
local notif_data = get_notif_data(client_id, token)
if notif_data.spinner then
@@ -28,16 +28,17 @@ local function update_spinner(client_id, token)
hide_from_history = true,
icon = spinner_frames[new_spinner],
replace = notif_data.notification,
title = title,
})
vim.defer_fn(function()
update_spinner(client_id, token)
update_spinner(client_id, token, title)
end, 100)
end
end
local function format_title(title, client_name)
return client_name .. (#title > 0 and ": " .. title or "")
return client_name .. (title and #title > 0 and ": " .. title or "")
end
local function format_message(message, percentage)
@@ -62,23 +63,25 @@ vim.lsp.handlers["$/progress"] = function(_, result, ctx)
local message = format_message(val.message, val.percentage)
notif_data.notification = vim.notify(message, "info", {
title = format_title(val.title, vim.lsp.get_client_by_id(client_id).name),
title = format_title("", vim.lsp.get_client_by_id(client_id).name),
icon = spinner_frames[1],
timeout = false,
hide_from_history = false,
})
notif_data.spinner = 1
update_spinner(client_id, result.token)
update_spinner(client_id, result.token, val.title)
elseif val.kind == "report" and notif_data then
notif_data.notification = vim.notify(format_message(val.message, val.percentage), "info", {
replace = notif_data.notification,
title = format_title("", vim.lsp.get_client_by_id(client_id).name),
hide_from_history = false,
})
elseif val.kind == "end" and notif_data then
notif_data.notification = vim.notify(val.message and format_message(val.message) or "Complete", "info", {
icon = "",
replace = notif_data.notification,
title = format_title("", vim.lsp.get_client_by_id(client_id).name),
timeout = 3000,
})
@@ -95,7 +98,7 @@ vim.lsp.handlers["window/showMessage"] = function(err, result, ctx)
"DEBUG",
})[result.type]
vim.notify("LSP Message: " .. result.message, lvl, {
title = "LSP | " .. client.name,
title = client.name,
timeout = 5000,
keep = function()
return lvl == "ERROR" or lvl == "WARN"

View File

@@ -1,4 +1,38 @@
return {
"stevearc/conform.nvim",
opts = {},
opts = {
on_init = function(client)
require("conform").formatters.shfmt = {
append_args = { "-i", "0", "-ci", "-sr" },
}
end,
formatters_by_ft = {
python = function(bufnr)
if require("conform").get_formatter_info("ruff_format", bufnr).available then
return {
"ruff_fix",
"ruff_format",
"ruff_organize_imports",
}
else
return { "isort", "black" }
end
end,
sh = { "shfmt" },
lua = { "stylua" },
go = { "goimports", "gofmt" },
javascript = { "prettier" },
javascriptreact = { "prettier" },
typescript = { "prettier" },
typescriptreact = { "prettier" },
md = { "markdownlint" },
["*"] = { "codespell" },
["_"] = { "trim_whitespace" },
},
format_on_save = {
-- These options will be passed to conform.format()
timeout_ms = 500,
-- lsp_format = "fallback",
},
},
}

View File

@@ -1,19 +1,3 @@
local function set_python_path(path)
local clients = vim.lsp.get_clients({
bufnr = vim.api.nvim_get_current_buf(),
name = "basedpyright",
})
for _, client in ipairs(clients) do
if client.settings then
client.settings.python = vim.tbl_deep_extend("force", client.settings.python or {}, { pythonPath = path })
else
client.config.settings =
vim.tbl_deep_extend("force", client.config.settings, { python = { pythonPath = path } })
end
client:notify("workspace/didChangeConfiguration", { settings = nil })
end
end
return {
"neovim/nvim-lspconfig",
config = function()
@@ -37,6 +21,7 @@ return {
"docker_compose_language_service",
"golangci_lint_ls",
"gopls",
"ruff",
}
-- Define the highlight color for float border
vim.api.nvim_set_hl(0, "FloatBorder", { fg = "#89b4fa", bold = true })
@@ -93,40 +78,55 @@ return {
vim.lsp.enable(lsp)
elseif lsp == "basedpyright" then
vim.lsp.config(lsp, {
on_init = function(client)
client.config.settings.basedpyright =
vim.tbl_deep_extend("force", client.config.settings.basedpyright, {
analysis = {
autoSearchPaths = true,
diagnosticMode = "openFilesOnly",
useLibraryCodeForTypes = true,
autoFormatStrings = true,
},
settings = {
basedpyright = {
analysis = {
autoSearchPaths = true,
diagnosticMode = "openFilesOnly",
inlayHints = {
callArgumentNames = true,
},
allowedUntypedLibraries = true,
reportMissingTypeStubs = true,
reportImportCycles = true,
reportUnusedImport = true,
})
end,
useLibraryCodeForTypes = true,
autoFormatStrings = true,
},
diagnosticMode = "openFilesOnly",
inlayHints = {
callArgumentNames = true,
},
allowedUntypedLibraries = true,
reportMissingTypeStubs = true,
reportImportCycles = true,
reportUnusedImport = true,
},
python = {
analysis = {
ignore = { "*" },
},
},
},
})
vim.lsp.enable(lsp)
else
vim.lsp.enable(lsp)
-- vim.lsp.config(lsp, {
-- handlers = {
-- UNNSUUPPORTED
-- ["textDocument/signatureHelp"] = vim.lsp.with(
-- vim.lsp.handlers.signature_help,
-- { border = border }
-- ),
-- ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }),
-- },
-- })
elseif lsp == "ruff" then
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("lsp_attach_disable_ruff_hover", { clear = true }),
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client == nil then
return
end
if client.name == "ruff" then
-- Disable hover in favor of Pyright
client.server_capabilities.hoverProvider = false
end
end,
desc = "LSP: Disable hover capability from Ruff",
})
vim.lsp.config(lsp, {
init_options = {
settings = {
configuration = vim.fn.stdpath("config") .. "lua/utils/ruff.toml",
},
},
})
end
vim.lsp.enable(lsp)
end
end,
}

View File

@@ -16,8 +16,8 @@ return {
},
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["vim.lsp.util.convert_input_to_markdown_lines"] = false,
["vim.lsp.util.stylize_markdown"] = false,
["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp
},
hover = {
@@ -30,7 +30,7 @@ return {
signature = {
enabled = true,
auto_open = {
enabled = false,
enabled = true,
trigger = true, -- Automatically show signature help when typing a trigger character from the LSP
luasnip = true, -- Will open signature help when jumping to Luasnip insert nodes
throttle = 50, -- Debounce lsp signature help request by 50ms
@@ -81,6 +81,48 @@ return {
},
},
},
popupmenu = {
enabled = true, -- enables the Noice popupmenu UI
---@type 'nui'|'cmp'
backend = "cmp", -- backend to use to show regular cmdline completions
---@type NoicePopupmenuItemKind|false
-- Icons for completion item kinds (see defaults at noice.config.icons.kinds)
kind_icons = {}, -- set to `false` to disable icons
},
notify = {
-- Noice can be used as `vim.notify` so you can route any notification like other messages
-- Notification messages have their level and other properties set.
-- event is always "notify" and kind can be any log level as a string
-- The default routes will forward notifications to nvim-notify
-- Benefit of using Noice for this is the routing and consistent history view
enabled = true,
view = "notify",
},
documentation = {
view = "hover",
---@type NoiceViewOptions
opts = {
lang = "markdown",
replace = true,
render = "plain",
format = { "{message}" },
win_options = { concealcursor = "n", conceallevel = 3 },
},
},
markdown = {
hover = {
["|(%S-)|"] = vim.cmd.help, -- vim help links
["%[.-%]%((%S-)%)"] = require("noice.util").open, -- markdown links
},
highlights = {
["|%S-|"] = "@text.reference",
["@%S+"] = "@parameter",
["^%s*(Parameters:)"] = "@text.title",
["^%s*(Return:)"] = "@text.title",
["^%s*(See also:)"] = "@text.title",
["{%S-}"] = "@parameter",
},
},
},
dependencies = {
-- if you lazy-load any plugin below, make sure to add proper `module="..."` entries

View File

@@ -1,75 +0,0 @@
return {
"nvimtools/none-ls.nvim",
config = function()
local null_ls = require("null-ls")
local helpers = require("null-ls.helpers")
-- syncronous formatting
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
local sources = {
null_ls.builtins.completion.luasnip,
-- null_ls.builtins.diagnostics.mypy,
null_ls.builtins.diagnostics.pydoclint,
null_ls.builtins.diagnostics.markdownlint,
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.isort,
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.markdownlint,
null_ls.builtins.formatting.prettier, -- handled by lsp server
null_ls.builtins.formatting.shfmt.with({
filetypes = { "sh", "bash" },
extra_args = { "-i", "0", "-ci", "-sr" },
}),
null_ls.builtins.formatting.gofmt,
null_ls.builtins.formatting.goimports,
null_ls.builtins.formatting.goimports_reviser,
null_ls.builtins.hover.printenv,
}
require("null-ls").setup({
border = "rounded",
cmd = { "nvim" },
debounce = 250,
debug = false,
default_timeout = 5000,
diagnostic_config = {
virtual_text = false,
signs = true,
underline = true,
float = { border = "rounded", source = true },
severity_sort = true,
},
-- diagnostics_format = "#{m}",
diagnostics_format = "[#{c}] #{m} (#{s})",
fallback_severity = vim.diagnostic.severity.ERROR,
log_level = "warn",
notify_format = "[null-ls] %s",
on_init = nil,
on_exit = nil,
root_dir = require("null-ls.utils").root_pattern(".null-ls-root", "Makefile", ".git"),
root_dir_async = nil,
should_attach = nil,
sources = sources,
temp_dir = nil,
update_in_insert = false,
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({
async = false,
bufnr = bufnr,
filter = function(client)
return client.name == "null-ls"
end,
})
end,
})
end
end,
})
end,
}

View File

@@ -5,7 +5,7 @@ return {
lint.linters_by_ft = {
markdown = { "markdownlint" },
lua = { "luacheck" },
py = { "flake8", "pylint", "pydocstyle", "pycodestyle", "mypy" },
python = { "ruff" },
sh = { "shellcheck" },
json = { "jsonlint" },
yaml = { "yamllint" },