Merge branch 'main' of github.com:esensar/dotfiles

main
Ensar Sarajčić 2022-05-13 09:40:01 +02:00
commit 8eb16cd850
11 changed files with 39 additions and 74 deletions

View File

@ -30,13 +30,13 @@ vim.api.nvim_create_user_command("PlenaryTestFile", function()
last_path = vim.fn.expand("%:p")
require("plenary.test_harness").test_directory(last_path, get_plenary_test_opts())
end, {})
end, { desc = "Test current file using plenary.nvim" })
vim.api.nvim_create_user_command("PlenaryTestSuite", function()
last_path = vim.fn["projectionist#path"]()
require("plenary.test_harness").test_directory(last_path, get_plenary_test_opts())
end, {})
end, { desc = "Run all tests using plenary.nvim" })
vim.api.nvim_create_user_command("PlenaryTestLast", function()
if not last_path then
@ -44,7 +44,7 @@ vim.api.nvim_create_user_command("PlenaryTestLast", function()
return
end
require("plenary.test_harness").test_directory(last_path, get_plenary_test_opts())
end, {})
end, { desc = "Run last run test using plenary.nvim" })
vim.api.nvim_create_user_command("PlenaryVisitLastTest", function()
if not last_path then
@ -52,7 +52,7 @@ vim.api.nvim_create_user_command("PlenaryVisitLastTest", function()
return
end
vim.cmd("edit " .. last_path)
end, {})
end, { desc = "Visit latest run test using plenary.nvim" })
local au_id = vim.api.nvim_create_augroup("plenary_test_group", {})
vim.api.nvim_create_autocmd("FileType", {

View File

@ -62,6 +62,14 @@ null_ls.setup({
vim.keymap.set("n", "]w", vim.diagnostic.goto_next)
vim.keymap.set("n", "[w", vim.diagnostic.goto_prev)
vim.api.nvim_create_user_command("Warnings", vim.diagnostic.setqflist, {})
vim.api.nvim_create_user_command("WarningsLoc", vim.diagnostic.setloclist, {})
vim.api.nvim_create_user_command("Format", vim.lsp.buf.formatting, {})
vim.api.nvim_create_user_command(
"Warnings",
vim.diagnostic.setqflist,
{ desc = "Show all LSP project warning in a quickfix list" }
)
vim.api.nvim_create_user_command(
"WarningsLoc",
vim.diagnostic.setloclist,
{ desc = "Show LSP buffer warnings in a location list" }
)
vim.api.nvim_create_user_command("Format", vim.lsp.buf.formatting, { desc = "Format current buffer using LSP" })

View File

@ -44,7 +44,7 @@ end
-- Opens up a rest console which can be saved -- cached by name
function M.open_cached_rest_console(args)
local name = args[0] or args[1]
if not name then
if string.len(name) == 0 then
name = require("esensar.common.projects").get_project_id()
end
open_cached_rest_console(name)

View File

@ -23,15 +23,15 @@ vim.keymap.set("n", "<leader>dsi", dap.step_into)
-- Neovim Lua debugging
vim.api.nvim_create_user_command("NeovimDebugStart", function()
require("osv").launch()
end, {})
end, { desc = "Start debugging neovim" })
vim.api.nvim_create_user_command("NeovimDebugThis", function()
require("osv").run_this()
end, {})
end, { desc = "Start debugging this neovim lua script" })
-- Vscode launch.json support
vim.api.nvim_create_user_command("DapLoadVsCodeLaunch", function(args)
require("dap.ext.vscode").load_launchjs(args.args)
end, {})
end, { desc = "Load VsCode launch.json for DAP" })
-- Nvim DAP UI
local dapui = require("dapui")

View File

@ -4,4 +4,4 @@
vim.api.nvim_create_user_command("EditLocalVimrc", function(_)
require("esensar.direnv_vimrc_local").open_local_vimrc()
end, { nargs = 0 })
end, { nargs = 0, desc = "Open or create project local .vimrc file" })

View File

@ -117,7 +117,7 @@ end
vim.api.nvim_create_user_command("LuaPopup", function()
popup_and_run(popup_type.lua)
end, {})
end, { desc = "Show a popup for writing lua code that will be executed after closing" })
vim.api.nvim_create_user_command("LuaPopupRestore", function()
if get_last_win(popup_type.lua) then
@ -125,11 +125,11 @@ vim.api.nvim_create_user_command("LuaPopupRestore", function()
else
vim.notify("No popup to restore! Use :LuaPopup first!", vim.log.levels.WARN)
end
end, {})
end, { desc = "Restore last popup displayed with LuaPopup command" })
vim.api.nvim_create_user_command("FennelPopup", function()
popup_and_run(popup_type.fennel)
end, {})
end, { desc = "Show a popup for writing fennel code that will be executed after closing" })
vim.api.nvim_create_user_command("FennelPopupRestore", function()
if get_last_win(popup_type.fennel) then
@ -137,4 +137,4 @@ vim.api.nvim_create_user_command("FennelPopupRestore", function()
else
vim.notify("No popup to restore! Use :FennelPopup first!", vim.log.levels.WARN)
end
end, {})
end, { desc = "Restore last popup displayed with FennelPopup command" })

View File

@ -1,50 +0,0 @@
-- Popupterm - get a popup with terminal buffer
local popup = require("nui.popup")
local event = require("nui.utils.autocmd").event
local last_term_win
local function popup_terminal()
if last_term_win then
last_term_win:show()
return
end
local win = popup({
enter = true,
focusable = true,
border = {
style = "rounded",
},
position = "50%",
size = {
width = "80%",
height = "60%",
},
})
-- mount/open the component
win:mount()
vim.cmd("edit term://" .. vim.env.SHELL)
-- map keys
win:map("n", "<Esc>", function(_)
win:hide()
end, { noremap = true })
-- unmount component when cursor leaves buffer
win:on(event.BufLeave, function()
win:hide()
end)
win:on(event.BufDelete, function()
last_term_win = nil
end)
last_term_win = win
end
vim.api.nvim_create_user_command("PopupTerm", function()
popup_terminal()
end, {})

View File

@ -6,14 +6,14 @@ local vim_rest_console_extensions = require("esensar.vim_rest_console_extensions
vim.api.nvim_create_user_command(
"ScratchRestConsole",
vim_rest_console_extensions.open_scratch_rest_console,
{ nargs = 0 }
{ nargs = 0, desc = "Open scratch RestConsole file - for testing HTTP calls" }
)
vim.api.nvim_create_user_command("RestConsole", function(args)
vim_rest_console_extensions.open_cached_rest_console(args.fargs)
end, { nargs = "?" })
end, { nargs = "?", desc = "Opens up a rest console which can be saved -- cached by name or project" })
vim.api.nvim_create_user_command("RestConsoleLocal", function(args)
vim_rest_console_extensions.open_local_rest_console(args.fargs)
end, { nargs = "?" })
end, { nargs = "?", desc = "Opens up a rest console based on local file path" })
vim.api.nvim_create_user_command("RestConsoleCached", function(args)
vim_rest_console_extensions.open_named_cached_rest_console(args.fargs[0] or args.fargs[1])
end, { nargs = 1 })
end, { nargs = 1, desc = "Opens up a rest console which can be saved -- cached by name and project" })

View File

@ -85,4 +85,4 @@ end
vim.api.nvim_create_user_command("BottomTerminal", function()
require("esensar.ui").new_bottom_split({})
vim.fn.termopen(os.getenv("SHELL"))
end, {})
end, { desc = "Open a terminal buffer at the bottom of the editor" })

View File

@ -1,3 +1,5 @@
-- Vim configuration utility commands
local function edit_vim_config()
vim.cmd("edit $VIMHOME/init.lua")
end
@ -11,9 +13,13 @@ local function reload_vim_config()
vim.cmd("source $MYVIMRC")
end
vim.api.nvim_create_user_command("EditVimConfig", edit_vim_config, {})
vim.api.nvim_create_user_command("EditVimPlugins", edit_vim_plugins, {})
vim.api.nvim_create_user_command("ReloadVimConfig", reload_vim_config, {})
vim.api.nvim_create_user_command(
"EditVimConfig",
edit_vim_config,
{ desc = "Edit vim configuration ($MYVIMRC - init.lua)" }
)
vim.api.nvim_create_user_command("EditVimPlugins", edit_vim_plugins, { desc = "Edit plugin list file" })
vim.api.nvim_create_user_command("ReloadVimConfig", reload_vim_config, { desc = "Reload init.lua and all lua files" })
vim.keymap.set("n", "<Leader>vec", edit_vim_config)
vim.keymap.set("n", "<Leader>vep", edit_vim_plugins)

View File

@ -11,3 +11,4 @@ lua 5.4.4
actionlint 1.6.12
act 0.2.26
shellcheck 0.8.0
cmake 3.22.3