Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/stephansama/nvim. neovim configuration for @stephansama
dotfiles lua neovim neovim-configuration nvim nvim-config typescript typescript-to-lua
Something went wrong. Try again.
Lua
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105local utils = require("utils")local SERVERS = require("plugins.lang").SERVERS
local capabilities = vim.tbl_deep_extend( "force", vim.lsp.protocol.make_client_capabilities(), require("blink.cmp").get_lsp_capabilities({}, false) )
capabilities = vim.tbl_deep_extend("force", capabilities, { textDocument = { foldingRange = { dynamicRegistration = false, lineFoldingOnly = true, }, },})
vim.lsp.config("*", { capabilities = capabilities })vim.lsp.enable(SERVERS)
local border = utils.border("FloatBorder")
local handler_opts = { border = border }
local handlers = { ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, handler_opts), ["textDocument/signatureHelp"] = vim.lsp.with( vim.lsp.handlers.signature_help, handler_opts ),}
for key, v in pairs(handlers) do vim.lsp.handlers[key] = vend
local diagnostic_source = "if_many"
local diagnostics = require("icons.init").diagnostics
vim.diagnostic.config({ float = { border = border, source = diagnostic_source, }, virtual_text = { source = diagnostic_source }, signs = { text = { [vim.diagnostic.severity.ERROR] = diagnostics.Error, [vim.diagnostic.severity.WARN] = diagnostics.Warn, [vim.diagnostic.severity.INFO] = diagnostics.Info, [vim.diagnostic.severity.HINT] = diagnostics.Hint, }, linehl = { [vim.diagnostic.severity.INFO] = "DiagnosticInfoMsg" }, numhl = { [vim.diagnostic.severity.WARN] = "WarningMsg" }, },})
-- To instead override globallylocal orig_util_open_floating_preview = vim.lsp.util.open_floating_preview---@diagnostic disable-next-line: duplicate-set-fieldvim.lsp.util.open_floating_preview = function(contents, syntax, opts, ...) opts = opts or {} ---@diagnostic disable-next-line: inject-field opts.border = opts.border or border return orig_util_open_floating_preview(contents, syntax, opts, ...)end
local function lsp_hover() local filetype = vim.bo.filetype
if vim.tbl_contains({ "vim", "help" }, filetype) then vim.cmd("h " .. vim.fn.expand("<cword>")) elseif vim.tbl_contains({ "man" }, filetype) then vim.cmd("Man " .. vim.fn.expand("<cword>")) elseif vim.fn.expand("%:t") == "package.json" then local text = vim.api.nvim_get_current_line()
if not require("utils.pkgjson").is_package(text) then return vim.lsp.buf.hover() end
local match = text:match('"(.-)"') local npm_link = require("config.constants").PACKAGE_JSON_URL .. match
vim.cmd("exec \"!open '" .. npm_link .. "'\"") elseif vim.fn.expand("%:t") == "Cargo.toml" and require( "crates" ).popup_available() then require("crates").show_popup() else local winid = require("ufo").peekFoldedLinesUnderCursor() if not winid then vim.lsp.buf.hover() end endend
if not _G.LspHoverCommandLoaded then _G.LspHoverCommandLoaded = true vim.api.nvim_create_user_command("LspHover", lsp_hover, { nargs = 0 })end