nvim: add neotest

This commit is contained in:
Fabio Lenherr / DashieTM 2023-09-21 19:26:09 +02:00
parent 993bd794f0
commit 46f4fdcc69
12 changed files with 333 additions and 196 deletions

View file

@ -102,7 +102,12 @@ return {
},
},
},
typst_lsp = {},
typst_lsp = {
settings = {
experimentalFormatterMode = "On",
exportPdf = "onSave",
},
},
ltex = {
settings = {
ltex = {
@ -120,6 +125,7 @@ return {
"tex",
"pandoc",
"typst",
"typ",
},
},
texlab = {},
@ -156,7 +162,7 @@ return {
require("lazyvim.plugins.lsp.format").autoformat = opts.autoformat
-- setup formatting and keymaps
require("lazyvim.util").on_attach(function(client, buffer)
require("lazyvim.plugins.lsp.format").setup(opts)
require("lazyvim.plugins.lsp.format").setup(opts)
require("config.lsp-keymap").on_attach(client, buffer)
end)

View file

@ -3,6 +3,7 @@ return {
"LazyVim/LazyVim",
opts = {
colorscheme = "tokyonight-night",
-- colorscheme = "catppuccin-mocha",
},
},
{
@ -15,31 +16,6 @@ return {
require("telescope").setup(opts)
end,
},
{
"akinsho/toggleterm.nvim",
lazy = true,
opts = {
autochdir = true,
},
},
{
"brenoprata10/nvim-highlight-colors",
lazy = true,
event = { "BufReadPre", "BufNewFile" },
config = function(_, _)
require("nvim-highlight-colors").setup({
enable_tailwind = true,
})
vim.cmd(":hi clear CursorLine")
vim.cmd(":hi clear CursorLineFold")
vim.cmd(":hi clear CursorLineSign")
end,
},
{
"gpanders/editorconfig.nvim",
event = { "BufReadPre", "BufNewFile" },
lazy = true,
},
{
"lvimuser/lsp-inlayhints.nvim",
event = { "BufReadPre", "BufNewFile" },
@ -107,7 +83,6 @@ return {
{
"lervag/vimtex",
config = function()
-- require("vimtex").setup()
vim.cmd("let g:vimtex_quickfix_mode=0")
vim.cmd("let g:vimtex_view_general_viewer = 'evince'")
vim.cmd("let g:vimtex_compiler_method = 'latexmk'")
@ -212,4 +187,169 @@ return {
{
"mg979/vim-visual-multi",
},
{
"rouge8/neotest-rust",
},
{
"Issafalcon/neotest-dotnet",
},
{
"andy-bell101/neotest-java",
},
{
"nvim-neotest/neotest-go",
},
{
"nvim-neotest/neotest-python",
},
{
"nvim-neotest/neotest",
dependencies = {
"rouge8/neotest-rust",
"Issafalcon/neotest-dotnet",
"andy-bell101/neotest-java",
"nvim-neotest/neotest-go",
"nvim-neotest/neotest-python",
},
opts = {
adapters = {
["neotest-rust"] = {},
["neotest-dotnet"] = {},
["neotest-java"] = {},
["neotest-go"] = {},
["neotest-python"] = {},
},
status = { virtual_text = true },
output = { open_on_run = true },
quickfix = {
open = function()
if require("lazyvim.util").has("trouble.nvim") then
vim.cmd("Trouble quickfix")
else
vim.cmd("copen")
end
end,
},
},
config = function(_, opts)
local neotest_ns = vim.api.nvim_create_namespace("neotest")
vim.diagnostic.config({
virtual_text = {
format = function(diagnostic)
-- Replace newline and tab characters with space for more compact diagnostics
local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
return message
end,
},
}, neotest_ns)
if opts.adapters then
local adapters = {}
for name, config in pairs(opts.adapters or {}) do
if type(name) == "number" then
if type(config) == "string" then
config = require(config)
end
adapters[#adapters + 1] = config
elseif config ~= false then
local adapter = require(name)
if type(config) == "table" and not vim.tbl_isempty(config) then
local meta = getmetatable(adapter)
if adapter.setup then
adapter.setup(config)
elseif meta and meta.__call then
adapter(config)
else
error("Adapter " .. name .. " does not support setup")
end
end
adapters[#adapters + 1] = adapter
end
end
opts.adapters = adapters
end
require("neotest").setup(opts)
end,
-- stylua: ignore
keys = {
{ "<leader>tT", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" },
{ "<leader>tt", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" },
{ "<leader>tr", function() require("neotest").run.run() end, desc = "Run Nearest" },
{ "<leader>ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" },
{ "<leader>to", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" },
{ "<leader>tO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" },
{ "<leader>tS", function() require("neotest").run.stop() end, desc = "Stop" },
},
},
{
"echasnovski/mini.hipatterns",
event = "BufReadPre",
opts = function()
local hi = require("mini.hipatterns")
return {
-- custom LazyVim option to enable the tailwind integration
tailwind = {
enabled = true,
ft = { "typescriptreact", "javascriptreact", "css", "javascript", "typescript", "html" },
-- full: the whole css class will be highlighted
-- compact: only the color will be highlighted
style = "full",
},
highlighters = {
hex_color = hi.gen_highlighter.hex_color({ priority = 2000 }),
},
}
end,
config = function(_, opts)
-- backward compatibility
if opts.tailwind == true then
opts.tailwind = {
enabled = true,
ft = { "typescriptreact", "javascriptreact", "css", "javascript", "typescript", "html" },
style = "full",
}
end
if type(opts.tailwind) == "table" and opts.tailwind.enabled then
-- reset hl groups when colorscheme changes
vim.api.nvim_create_autocmd("ColorScheme", {
callback = function()
M.hl = {}
end,
})
opts.highlighters.tailwind = {
pattern = function()
if not vim.tbl_contains(opts.tailwind.ft, vim.bo.filetype) then
return
end
if opts.tailwind.style == "full" then
return "%f[%w:-]()[%w:-]+%-[a-z%-]+%-%d+()%f[^%w:-]"
elseif opts.tailwind.style == "compact" then
return "%f[%w:-][%w:-]+%-()[a-z%-]+%-%d+()%f[^%w:-]"
end
end,
group = function(_, _, m)
---@type string
local match = m.full_match
---@type string, number
local color, shade = match:match("[%w-]+%-([a-z%-]+)%-(%d+)")
shade = tonumber(shade)
local bg = vim.tbl_get(M.colors, color, shade)
if bg then
local hl = "MiniHipatternsTailwind" .. color .. shade
if not M.hl[hl] then
M.hl[hl] = true
local bg_shade = shade == 500 and 950 or shade < 500 and 900 or 100
local fg = vim.tbl_get(M.colors, color, bg_shade)
vim.api.nvim_set_hl(0, hl, { bg = "#" .. bg, fg = "#" .. fg })
end
return hl
end
end,
priority = 2000,
}
end
require("mini.hipatterns").setup(opts)
end,
},
}