mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 11:24:55 +02:00
nvim: moved stuff around.
This commit is contained in:
parent
300d300664
commit
0d7a5fab7b
22 changed files with 975 additions and 990 deletions
66
nvim/lua/user/plugins/ide/autocomplete.lua
Normal file
66
nvim/lua/user/plugins/ide/autocomplete.lua
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
local icons = require('user.icons')
|
||||
|
||||
return {
|
||||
'saghen/blink.cmp',
|
||||
lazy = false,
|
||||
version = "*",
|
||||
build = 'cargo build --release',
|
||||
dependencies = {
|
||||
{ "xzbdmw/colorful-menu.nvim" },
|
||||
{ 'L3MON4D3/LuaSnip', version = 'v2.*' },
|
||||
},
|
||||
opts = {
|
||||
keymap = {
|
||||
preset = "super-tab"
|
||||
},
|
||||
appearance = {
|
||||
nerd_font_variant = 'mono',
|
||||
kind_icons = icons.symbols
|
||||
},
|
||||
completion = {
|
||||
list = {
|
||||
selection = {
|
||||
preselect = function(ctx) return ctx.mode ~= 'cmdline' end,
|
||||
-- auto_insert = function(ctx) return ctx.mode ~= 'cmdline' end
|
||||
auto_insert = false
|
||||
}
|
||||
},
|
||||
menu = {
|
||||
min_width = 18,
|
||||
winblend = 10,
|
||||
draw = {
|
||||
columns = {
|
||||
{ "kind_icon" },
|
||||
{ "label", "source_name", gap = 1 },
|
||||
},
|
||||
components = {
|
||||
label = {
|
||||
text = function(ctx)
|
||||
return require("colorful-menu").blink_components_text(ctx)
|
||||
end,
|
||||
highlight = function(ctx)
|
||||
return require("colorful-menu").blink_components_highlight(ctx)
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
documentation = {
|
||||
auto_show = true,
|
||||
window = {
|
||||
winblend = 10
|
||||
}
|
||||
},
|
||||
ghost_text = {
|
||||
enabled = true,
|
||||
}
|
||||
},
|
||||
signature = {
|
||||
enabled = true,
|
||||
window = {
|
||||
scrollbar = false,
|
||||
winblend = 10,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
nvim/lua/user/plugins/ide/formatting.lua
Normal file
22
nvim/lua/user/plugins/ide/formatting.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
return {
|
||||
'stevearc/conform.nvim',
|
||||
opts = {
|
||||
default_format_opts = {
|
||||
lsp_format = "fallback"
|
||||
}
|
||||
},
|
||||
init = function()
|
||||
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
|
||||
user.formatter = function(args)
|
||||
local range = nil
|
||||
if args.count ~= -1 then
|
||||
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
|
||||
range = {
|
||||
start = { args.line1, 0 },
|
||||
["end"] = { args.line2, end_line:len() },
|
||||
}
|
||||
end
|
||||
require("conform").format({ async = true, range = range })
|
||||
end
|
||||
end
|
||||
}
|
||||
146
nvim/lua/user/plugins/ide/lsp.lua
Normal file
146
nvim/lua/user/plugins/ide/lsp.lua
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
optional = true,
|
||||
dependencies = {
|
||||
{ "williamboman/mason-lspconfig.nvim", config = function () end }
|
||||
}
|
||||
},
|
||||
-- LSP often return markdown that neovim parses.
|
||||
-- make sure we have a plugin that can render markdown to nicer text
|
||||
{
|
||||
'MeanderingProgrammer/render-markdown.nvim',
|
||||
dependencies = {
|
||||
'nvim-tree/nvim-web-devicons',
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "markdown", "markdown_inline" }
|
||||
}
|
||||
}
|
||||
},
|
||||
opts = {
|
||||
overrides = {
|
||||
buftype = {
|
||||
-- LSP Hover = "nofile"
|
||||
nofile = {
|
||||
code = { left_pad = 0, right_pad = 0 },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
--- @class LSPServerOptions : LSPFeatures
|
||||
--- @field server_capabilities? lsp.ServerCapabilities
|
||||
--- @field on_save function | nil
|
||||
|
||||
--- @class LSPFeatures
|
||||
--- @field document_highlight? { enabled: boolean }
|
||||
--- @field codelens? { enabled: boolean }
|
||||
--- @field inlay_hints? { enabled: boolean, exclude?: table }
|
||||
|
||||
--- @class LSPOptions
|
||||
opts = {
|
||||
--- @type LSPFeatures
|
||||
features = {
|
||||
document_highlight = {
|
||||
enabled = true,
|
||||
},
|
||||
codelens = {
|
||||
enabled = false,
|
||||
},
|
||||
inlay_hints = {
|
||||
enabled = true,
|
||||
exclude = {},
|
||||
},
|
||||
},
|
||||
--- @type { string: LSPServerOptions }
|
||||
servers = {},
|
||||
},
|
||||
--- @param opts LSPOptions
|
||||
config = function(_, opts)
|
||||
local lspconfig = require("lspconfig")
|
||||
local utils = require("user.utils.lsp")
|
||||
local augroup = vim.api.nvim_create_augroup("Lsp", {})
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
|
||||
--- @param server string
|
||||
local function setup(server)
|
||||
|
||||
local server_opts = opts.servers[server] or {}
|
||||
|
||||
if type(server_opts) == "function" then
|
||||
server_opts = server_opts()
|
||||
end
|
||||
|
||||
-- Set missing features to default ones in server options.
|
||||
server_opts = vim.tbl_deep_extend("keep", server_opts, opts.features)
|
||||
|
||||
---@param client vim.lsp.Client
|
||||
---@param bufnr number
|
||||
local on_attach = function(client, bufnr)
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
|
||||
-- Override any server capabilities.
|
||||
client.server_capabilities = vim.tbl_extend("force",
|
||||
client.server_capabilities,
|
||||
server_opts.server_capabilities or {})
|
||||
|
||||
if server_opts.inlay_hints.enabled and client.supports_method("textDocument/inlayHint") then
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||
end
|
||||
|
||||
if server_opts.codelens.enabled and client.supports_method("textDocument/codeLens") then
|
||||
utils.codelens(augroup, bufnr)
|
||||
end
|
||||
|
||||
if server_opts.document_highlight.enabled and client.supports_method("textDocument/documentHighlight") then
|
||||
utils.document_highlight(bufnr)
|
||||
end
|
||||
|
||||
-- Setup on save handler
|
||||
if server_opts.on_save then
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = server_opts.on_save,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
server_opts = vim.tbl_deep_extend("force", {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities
|
||||
}, server_opts or {})
|
||||
|
||||
lspconfig[server].setup(server_opts)
|
||||
end
|
||||
|
||||
local have_mason, mlsp = pcall(require, "mason-lspconfig")
|
||||
|
||||
local all_mslp_servers = {}
|
||||
if have_mason then
|
||||
all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package)
|
||||
end
|
||||
|
||||
local ensure_installed = {} ---@type string[]
|
||||
for name, server_opts in pairs(opts.servers) do
|
||||
if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, name) then
|
||||
setup(name)
|
||||
else
|
||||
ensure_installed[#ensure_installed + 1] = name
|
||||
end
|
||||
end
|
||||
|
||||
if have_mason then
|
||||
mlsp.setup({
|
||||
ensure_installed = ensure_installed,
|
||||
handlers = { setup },
|
||||
})
|
||||
end
|
||||
end,
|
||||
}
|
||||
45
nvim/lua/user/plugins/ide/test.lua
Normal file
45
nvim/lua/user/plugins/ide/test.lua
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
local icons = require('user.icons')
|
||||
|
||||
return {
|
||||
"nvim-neotest/neotest",
|
||||
dependencies = {
|
||||
"nvim-neotest/nvim-nio",
|
||||
"nvim-lua/plenary.nvim",
|
||||
"antoinemadec/FixCursorHold.nvim",
|
||||
"nvim-treesitter/nvim-treesitter"
|
||||
},
|
||||
opts = {
|
||||
floating = {
|
||||
border = "none",
|
||||
},
|
||||
output = {
|
||||
enabled = true,
|
||||
open_on_run = true,
|
||||
},
|
||||
icons = {
|
||||
child_indent = icons.tree.vertical,
|
||||
child_prefix = icons.tree.node,
|
||||
collapsed = icons.tree.horizontal,
|
||||
non_collapsible = icons.tree.horizontal,
|
||||
expanded = icons.tree.expanded,
|
||||
final_child_indent = " ",
|
||||
final_child_prefix = icons.tree.nodelast,
|
||||
running_animated = { "⠋", "⠙", "⠚", "⠞", "⠖", "⠦", "⠴", "⠲", "⠳", "⠓" },
|
||||
passed = icons.test.ok,
|
||||
failed = icons.test.failed,
|
||||
running = icons.test.running,
|
||||
skipped = icons.test.skipped,
|
||||
unknown = icons.test.unknown,
|
||||
watching = icons.test.watch,
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
local adapters = {}
|
||||
for name, adapter_opts in pairs(opts.adapters or {}) do
|
||||
table.insert(adapters, require(name)(adapter_opts))
|
||||
end
|
||||
opts.adapters = adapters
|
||||
require('neotest').setup(opts)
|
||||
end
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue