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

@ -31,15 +31,25 @@ map("n", "<leader>dc", ':lua require("dap").continue()<CR>', { desc = "Continue"
map("n", "<leader>dt", ':lua require("dap").continue()<CR> :lua require("dapui").toggle()<CR>', { desc = "Open DAP" })
map("n", "<leader>dq", ':lua require("dapui").toggle()<CR> :lua require("dap").close()<CR>', { desc = "Close DAP" })
-- window movement
map("n", "<A-j>", [[<Cmd>wincmd h<CR>]], opts)
map("n", "<A-;>", [[<Cmd>wincmd l<CR>]], opts)
map("n", "<A-t>", [[<Cmd>wincmd j<CR>]], opts)
map("i", "<A-j>", [[<Cmd>wincmd h<CR>]], opts)
map("i", "<A-;>", [[<Cmd>wincmd l<CR>]], opts)
map("i", "<A-k>", [[<Cmd>wincmd j<CR>]], opts)
-- file tree
map("n", "<A-f>", function()
require("nvim-tree.api").tree.toggle()
end, opts)
-- toggle terminal
map("n", "<C-t>", function()
require("toggleterm").toggle(1)
end, { desc = "Toggle Terminal" })
local lazyterm = function()
Util.float_term(nil, { cwd = Util.get_root() })
end
map("n", "<c-t>", lazyterm, { desc = "Terminal (root dir)" })
map("t", "<C-t>", "<cmd>close<cr>", { desc = "Hide Terminal" })
-- semicolon thing
-- map("i","<C-m>" ,"<C-o>A;<CR>", {desc = "add semi and newline"})
@ -78,37 +88,6 @@ map("n", "<leader>gb", function()
vim.cmd(":GitBlameToggle")
end, { desc = "gitui (cwd)" })
-- window switching
function _G.set_terminal_maps()
local opts = { buffer = 0 }
vim.keymap.set("t", "<esc>", [[<C-\><C-n>]], opts)
vim.keymap.set("t", "jk", [[<C-\><C-n>]], opts)
vim.keymap.set("t", "<A-h>", [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set("t", "<A-j>", [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set("n", "<C-t>", function()
require("toggleterm").toggle(1)
end, opts)
vim.keymap.set("i", "<C-t>", function()
require("toggleterm").toggle(1)
end, opts)
vim.keymap.set("t", "<C-t>", function()
require("toggleterm").toggle(1)
end, opts)
end
-- if you only want these mappings for toggle term use term://*toggleterm#* instead
vim.cmd("autocmd! TermOpen term://* lua set_terminal_maps()")
map("t", "<A-j>", [[<Cmd>wincmd h<CR>]], opts)
map("t", "<A-k>", [[<Cmd>wincmd j<CR>]], opts)
map("t", "<A-l>", [[<Cmd>wincmd k<CR>]], opts)
map("t", "<A-;>", [[<Cmd>wincmd l<CR>]], opts)
map("n", "<A-j>", [[<Cmd>wincmd h<CR>]], opts)
map("n", "<A-;>", [[<Cmd>wincmd l<CR>]], opts)
map("n", "<A-t>", [[<Cmd>wincmd j<CR>]], opts)
map("i", "<A-j>", [[<Cmd>wincmd h<CR>]], opts)
map("i", "<A-;>", [[<Cmd>wincmd l<CR>]], opts)
map("i", "<A-k>", [[<Cmd>wincmd j<CR>]], opts)
-- harpoon man
map("n", "<leader>h1", function()
require("harpoon.ui").nav_file(1)

View file

@ -11,12 +11,13 @@ require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "plugins.plugins" },
{ import = "plugins" },
-- import any extras modules here
-- { import = "lazyvim.plugins.extras.lang.typescript" },
-- { import = "lazyvim.plugins.extras.lang.json" },
-- { import = "lazyvim.plugins.extras.ui.mini-animate" },
-- import/override with your plugins
{ import = "plugins" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
@ -27,7 +28,7 @@ require("lazy").setup({
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
install = { colorscheme = { "tokyonight", "habamax" } },
install = { colorscheme = { "tokyonight", "catppuccin-mocha" } },
checker = { enabled = true, notify = false },
change_detection = { enabled = true, notify = false }, --know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
performance = {

View file

@ -7,9 +7,8 @@ M._keys = nil
function M.get()
local format = require("lazyvim.plugins.lsp.format").format
if not M._keys then
---@class PluginLspKeys
-- stylua: ignore
M._keys = {
---@class PluginLspKeys
M._keys = {
{ "<leader>cld", vim.diagnostic.open_float, desc = "Line Diagnostics" },
{ "<leader>cl", "<cmd>LspInfo<cr>", desc = "Lsp Info" },
{ "<leader>ca", "<cmd>Telescope lsp_definitions<cr>", desc = "Goto Definition", has = "definition" },
@ -28,23 +27,44 @@ function M.get()
{ "[w", M.diagnostic_goto(false, "WARN"), desc = "Prev Warning" },
{ "<F4>", format, desc = "Format Document", has = "documentFormatting" },
-- { "<leader>cf", format, desc = "Format Range", mode = "v", has = "documentRangeFormatting" },
{ "<leader>cq",function()
vim.lsp.buf.code_action({
{
"<leader>cq",
function()
vim.lsp.buf.code_action({
context = {
only = {
"quickfix",
"quickfix.ltex",
"source",
"source.fixAll",
"source.organizeImports",
"",
},
diagnostics = {},
},
})
end, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" },
})
end,
desc = "Fix",
mode = { "n", "v" },
has = "codeAction",
},
{
"<leader>cQ",
vim.lsp.buf.code_action,
desc = "Source Action",
function()
vim.lsp.buf.code_action({
context = {
only = {
"refactor",
"refactor.inline",
"refactor.extract",
"refactor.rewrite",
},
},
})
end,
desc = "Refactor",
mode = { "n", "v" },
has = "codeAction",
}
},
}
if require("lazyvim.util").has("inc-rename.nvim") then
M._keys[#M._keys + 1] = {