Compare commits
4 Commits
e142630914
...
157a5172ac
Author | SHA1 | Date |
---|---|---|
Rob Watson | 157a5172ac | |
Rob Watson | cffcfca318 | |
Rob Watson | e41673a9ca | |
Rob Watson | 7147da76cd |
|
@ -113,6 +113,7 @@
|
||||||
helper = !gh auth git-credential
|
helper = !gh auth git-credential
|
||||||
[diff]
|
[diff]
|
||||||
tool = vimdiff
|
tool = vimdiff
|
||||||
|
ignoreSubmodules = dirty
|
||||||
[merge]
|
[merge]
|
||||||
tool = vimdiff
|
tool = vimdiff
|
||||||
[interactive]
|
[interactive]
|
||||||
|
|
18
nvimrc
18
nvimrc
|
@ -295,6 +295,24 @@ packadd! vim-rhubarb " https://github.com/tpope/vim-rhubarb.git
|
||||||
packadd! editorconfig-vim " https://github.com/editorconfig/editorconfig-vim.git
|
packadd! editorconfig-vim " https://github.com/editorconfig/editorconfig-vim.git
|
||||||
packadd! vim-wordmotion " https://github.com/chaoren/vim-wordmotion.git
|
packadd! vim-wordmotion " https://github.com/chaoren/vim-wordmotion.git
|
||||||
|
|
||||||
|
" projectionist
|
||||||
|
packadd! vim-projectionist " https://github.com/tpope/vim-projectionist.git
|
||||||
|
|
||||||
|
let g:projectionist_heuristics = {
|
||||||
|
\ "*.go": {
|
||||||
|
\ "*_test.go": {
|
||||||
|
\ "type": "source",
|
||||||
|
\ "alternate": "{}.go",
|
||||||
|
\ },
|
||||||
|
\ "*.go": {
|
||||||
|
\ "type": "source",
|
||||||
|
\ "alternate": "{}_test.go",
|
||||||
|
\ },
|
||||||
|
\ "etc/rbenv.d/*.bash": {"type": "hook"}
|
||||||
|
\ }
|
||||||
|
\ }
|
||||||
|
nnoremap <leader>A :A<cr>
|
||||||
|
|
||||||
" aerial
|
" aerial
|
||||||
packadd! aerial.nvim " https://github.com/stevearc/aerial.nvim.git
|
packadd! aerial.nvim " https://github.com/stevearc/aerial.nvim.git
|
||||||
|
|
||||||
|
|
|
@ -1,42 +1,44 @@
|
||||||
local nvim_lsp = require("lspconfig")
|
local nvim_lsp = require("lspconfig")
|
||||||
|
|
||||||
|
vim.lsp.set_log_level("debug")
|
||||||
|
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(client, bufnr)
|
||||||
-- TODO: use vim.api.nvim_create_autocmd
|
-- TODO: use vim.api.nvim_create_autocmd
|
||||||
vim.api.nvim_exec2([[autocmd User LspDiagnosticsChanged call lightline#update()]], { output = false })
|
vim.api.nvim_exec2([[autocmd User LspDiagnosticsChanged call lightline#update()]], { output = false })
|
||||||
|
|
||||||
local opts = { noremap = true, silent = false }
|
local opts = { noremap = true, silent = false }
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<Cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<Cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>gD", "<Cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>gD", "<Cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>k", "<Cmd>lua vim.diagnostic.open_float()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>k", "<Cmd>lua vim.diagnostic.open_float()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>e", "<Cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>e", "<Cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>r", "<Cmd>lua vim.lsp.buf.references()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>r", "<Cmd>lua vim.lsp.buf.references()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>i", "<Cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>i", "<Cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<Cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<Cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ci", "<Cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ci", "<Cmd>lua vim.lsp.buf.incoming_calls()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>co", "<Cmd>lua vim.lsp.buf.outgoing_calls()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>co", "<Cmd>lua vim.lsp.buf.outgoing_calls()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "]e", '<Cmd>lua vim.diagnostic.goto_next({severity="Error"})<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "]e", '<Cmd>lua vim.diagnostic.goto_next({severity="Error"})<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "[e", '<Cmd>lua vim.diagnostic.goto_prev({severity="Error"})<CR>', opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "[e", '<Cmd>lua vim.diagnostic.goto_prev({severity="Error"})<CR>', opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", "<Cmd>lua vim.diagnostic.goto_next()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", "<Cmd>lua vim.diagnostic.goto_next()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", "<Cmd>lua vim.diagnostic.goto_prev()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", "<Cmd>lua vim.diagnostic.goto_prev()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "cd", "<Cmd>lua vim.diagnostic.hide(nil, 0)<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "cd", "<Cmd>lua vim.diagnostic.hide(nil, 0)<CR>", opts)
|
||||||
|
|
||||||
-- fzf triggers:
|
-- fzf triggers:
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fr", "<Cmd>References<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fr", "<Cmd>References<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fi", "<Cmd>Implementations<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fi", "<Cmd>Implementations<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fs", "<Cmd>DocumentSymbols<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fs", "<Cmd>DocumentSymbols<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fw", "<Cmd>WorkspaceSymbols<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fw", "<Cmd>WorkspaceSymbols<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fc", "<Cmd>CodeActions<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fc", "<Cmd>CodeActions<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fci", "<Cmd>IncomingCalls<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fci", "<Cmd>IncomingCalls<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fco", "<Cmd>OutgoingCalls<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>fco", "<Cmd>OutgoingCalls<CR>", opts)
|
||||||
|
|
||||||
require("lsp_signature").on_attach({
|
require("lsp_signature").on_attach({
|
||||||
hint_enable = false,
|
hint_enable = false,
|
||||||
})
|
})
|
||||||
|
|
||||||
require("copilot_cmp").setup()
|
require("copilot_cmp").setup()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Go
|
-- Go
|
||||||
|
@ -44,42 +46,46 @@ end
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
capabilities.textDocument.completion.completionItem.snippetSupport = false
|
capabilities.textDocument.completion.completionItem.snippetSupport = false
|
||||||
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||||
properties = {
|
properties = {
|
||||||
"documentation",
|
"documentation",
|
||||||
"detail",
|
"detail",
|
||||||
"additionalTextEdits",
|
"additionalTextEdits",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
nvim_lsp.gopls.setup({
|
nvim_lsp.gopls.setup({
|
||||||
settings = {
|
settings = {
|
||||||
gopls = {
|
gopls = {
|
||||||
staticcheck = true,
|
staticcheck = true,
|
||||||
-- Disabling linksInHover may not be working as expected:
|
-- Disabling linksInHover may not be working as expected:
|
||||||
linksInHover = false,
|
linksInHover = false,
|
||||||
usePlaceholders = true,
|
usePlaceholders = true,
|
||||||
experimentalPostfixCompletions = true,
|
experimentalPostfixCompletions = true,
|
||||||
analyses = {
|
analyses = {
|
||||||
unusedparams = true,
|
unusedparams = true,
|
||||||
shadow = true,
|
shadow = true,
|
||||||
unusedwrite = true,
|
unusedwrite = true,
|
||||||
unusedresult = true,
|
unusedresult = true,
|
||||||
nilness = true,
|
nilness = true,
|
||||||
},
|
},
|
||||||
buildFlags = { "-tags=acceptance" },
|
buildFlags = { "-tags=acceptance,basketapitest,graphqlapitest" }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
init_options = {
|
init_options = {
|
||||||
usePlaceholders = true,
|
usePlaceholders = true,
|
||||||
},
|
},
|
||||||
capabilities = vim.tbl_extend("error", capabilities, {
|
capabilities = vim.tbl_extend(
|
||||||
workspace = {
|
"error",
|
||||||
didChangeWatchedFiles = {
|
capabilities,
|
||||||
dynamicRegistration = true,
|
{
|
||||||
},
|
workspace = {
|
||||||
},
|
didChangeWatchedFiles = {
|
||||||
}),
|
dynamicRegistration = true
|
||||||
on_attach = on_attach,
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
),
|
||||||
|
on_attach = on_attach,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Rust
|
-- Rust
|
||||||
|
@ -112,58 +118,58 @@ nvim_lsp.rust_analyzer.setup({
|
||||||
-- Ruby
|
-- Ruby
|
||||||
|
|
||||||
nvim_lsp.solargraph.setup({
|
nvim_lsp.solargraph.setup({
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
settings = {
|
settings = {
|
||||||
solargraph = {
|
solargraph = {
|
||||||
autoformat = false,
|
autoformat = false,
|
||||||
formatting = false,
|
formatting = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Typescript
|
-- Typescript
|
||||||
-- https://jose-elias-alvarez.medium.com/configuring-neovims-lsp-client-for-typescript-development-5789d58ea9c
|
-- https://jose-elias-alvarez.medium.com/configuring-neovims-lsp-client-for-typescript-development-5789d58ea9c
|
||||||
|
|
||||||
nvim_lsp.ts_ls.setup({
|
nvim_lsp.ts_ls.setup({
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
})
|
})
|
||||||
|
|
||||||
local filetypes = {
|
local filetypes = {
|
||||||
typescript = "eslint",
|
typescript = "eslint",
|
||||||
typescriptreact = "eslint",
|
typescriptreact = "eslint",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- diagnosticls
|
-- diagnosticls
|
||||||
|
|
||||||
local linters = {
|
local linters = {
|
||||||
eslint = {
|
eslint = {
|
||||||
sourceName = "eslint",
|
sourceName = "eslint",
|
||||||
-- fallback to global eslint if the local is not found?
|
-- fallback to global eslint if the local is not found?
|
||||||
-- https://github.com/creativenull/diagnosticls-configs-nvim/blob/e7d6f7e99f6b416d2aeee89314bc46fc36df7b22/lua/diagnosticls-configs/fs.lua#L20
|
-- https://github.com/creativenull/diagnosticls-configs-nvim/blob/e7d6f7e99f6b416d2aeee89314bc46fc36df7b22/lua/diagnosticls-configs/fs.lua#L20
|
||||||
command = "./node_modules/.bin/eslint",
|
command = "./node_modules/.bin/eslint",
|
||||||
rootPatterns = { ".eslintrc", ".eslintrc.js" },
|
rootPatterns = { ".eslintrc", ".eslintrc.js" },
|
||||||
debounce = 100,
|
debounce = 100,
|
||||||
args = { "--stdin", "--stdin-filename", "%filepath", "--format", "json" },
|
args = { "--stdin", "--stdin-filename", "%filepath", "--format", "json" },
|
||||||
parseJson = {
|
parseJson = {
|
||||||
errorsRoot = "[0].messages",
|
errorsRoot = "[0].messages",
|
||||||
line = "line",
|
line = "line",
|
||||||
column = "column",
|
column = "column",
|
||||||
endLine = "endLine",
|
endLine = "endLine",
|
||||||
endColumn = "endColumn",
|
endColumn = "endColumn",
|
||||||
message = "${message} [${ruleId}]",
|
message = "${message} [${ruleId}]",
|
||||||
security = "severity",
|
security = "severity",
|
||||||
},
|
},
|
||||||
securities = { [1] = "error", [2] = "warning" },
|
securities = { [1] = "error", [2] = "warning" },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
nvim_lsp.diagnosticls.setup({
|
nvim_lsp.diagnosticls.setup({
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
filetypes = vim.tbl_keys(filetypes),
|
filetypes = vim.tbl_keys(filetypes),
|
||||||
init_options = {
|
init_options = {
|
||||||
linters = linters,
|
linters = linters,
|
||||||
filetypes = filetypes,
|
filetypes = filetypes,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Lua
|
-- Lua
|
||||||
|
@ -173,35 +179,35 @@ table.insert(runtime_path, "lua/?.lua")
|
||||||
table.insert(runtime_path, "lua/?/init.lua")
|
table.insert(runtime_path, "lua/?/init.lua")
|
||||||
|
|
||||||
nvim_lsp.lua_ls.setup({
|
nvim_lsp.lua_ls.setup({
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
runtime = {
|
runtime = {
|
||||||
version = "LuaJIT",
|
version = "LuaJIT",
|
||||||
path = runtime_path,
|
path = runtime_path,
|
||||||
},
|
},
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
globals = { "vim" },
|
globals = { "vim" },
|
||||||
},
|
},
|
||||||
workspace = {
|
workspace = {
|
||||||
library = vim.api.nvim_get_runtime_file("", true),
|
library = vim.api.nvim_get_runtime_file("", true),
|
||||||
},
|
},
|
||||||
telemetry = {
|
telemetry = {
|
||||||
enable = false,
|
enable = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Bash language server
|
-- Bash language server
|
||||||
|
|
||||||
-- https://github.com/bash-lsp/bash-language-server#neovim
|
-- https://github.com/bash-lsp/bash-language-server#neovim
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
pattern = "sh",
|
pattern = "sh",
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.lsp.start({
|
vim.lsp.start({
|
||||||
name = "bash-language-server",
|
name = "bash-language-server",
|
||||||
cmd = { "bash-language-server", "start" },
|
cmd = { "bash-language-server", "start" },
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,108 +1,108 @@
|
||||||
_G._test_cmd_to_wins = {}
|
_G._test_cmd_to_wins = {}
|
||||||
|
|
||||||
_G._build_test_cmd = function()
|
_G._build_test_cmd = function()
|
||||||
local bufnr = vim.fn.bufnr("%")
|
local bufnr = vim.fn.bufnr("%")
|
||||||
local filetype = vim.fn.getbufvar(bufnr, "&filetype")
|
local filetype = vim.fn.getbufvar(bufnr, "&filetype")
|
||||||
if filetype == "" then
|
if filetype == "" then
|
||||||
vim.api.nvim_err_writeln("cannot build test command for filetype:" .. filetype)
|
vim.api.nvim_err_writeln("cannot build test command for filetype:" .. filetype)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local path = vim.fn.expand("%:p")
|
local path = vim.fn.expand("%:p")
|
||||||
|
|
||||||
-- TODO: allow line number to be passed
|
-- TODO: allow line number to be passed
|
||||||
-- TODO: check file exists before running command
|
-- TODO: check file exists before running command
|
||||||
if filetype == "ruby" then
|
if filetype == "ruby" then
|
||||||
if not path:find("_spec.rb") then
|
if not path:find("_spec.rb") then
|
||||||
path = path:gsub("/app/", "/spec/"):gsub([[.rb$]], "_spec.rb")
|
path = path:gsub("/app/", "/spec/"):gsub([[.rb$]], "_spec.rb")
|
||||||
end
|
end
|
||||||
|
|
||||||
return "bundle exec rspec --format=progress --no-profile " .. path
|
return "bundle exec rspec --format=progress --no-profile " .. path
|
||||||
elseif filetype == "go" then
|
elseif filetype == "go" then
|
||||||
return "go test -v " .. path:gsub("^(.*)/(.*go)$", "%1/...")
|
return "go test -v " .. path:gsub("^(.*)/(.*go)$", "%1/...")
|
||||||
elseif filetype == "typescript" or filetype == "javascript" then
|
elseif filetype == "typescript" or filetype == "javascript" then
|
||||||
return "pnpm test -- " .. path
|
return "pnpm test -- " .. path
|
||||||
else
|
else
|
||||||
vim.api.nvim_err_writeln("filetype not supported: " .. filetype)
|
vim.api.nvim_err_writeln("filetype not supported: " .. filetype)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_G.run_tests = function()
|
_G.run_tests = function()
|
||||||
local cmd = _G._build_test_cmd()
|
local cmd = _G._build_test_cmd()
|
||||||
if cmd == nil then
|
if cmd == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_command([[silent up]])
|
vim.api.nvim_command([[silent up]])
|
||||||
|
|
||||||
local winid = _G._test_cmd_to_wins[cmd]
|
local winid = _G._test_cmd_to_wins[cmd]
|
||||||
local current_winid = vim.fn.win_getid()
|
local current_winid = vim.fn.win_getid()
|
||||||
if
|
if
|
||||||
winid == nil
|
winid == nil
|
||||||
or not vim.api.nvim_win_is_valid(winid)
|
or not vim.api.nvim_win_is_valid(winid)
|
||||||
or winid == current_winid
|
or winid == current_winid
|
||||||
or not vim.fn.win_gotoid(winid) == -1
|
or not vim.fn.win_gotoid(winid) == -1
|
||||||
then
|
then
|
||||||
vim.api.nvim_command([[10split]])
|
vim.api.nvim_command([[10split]])
|
||||||
winid = vim.fn.win_getid()
|
winid = vim.fn.win_getid()
|
||||||
_G._test_cmd_to_wins[cmd] = winid
|
_G._test_cmd_to_wins[cmd] = winid
|
||||||
end
|
end
|
||||||
|
|
||||||
local buf = vim.api.nvim_create_buf(false, true)
|
local buf = vim.api.nvim_create_buf(false, true)
|
||||||
vim.api.nvim_buf_set_option(buf, "bufhidden", "delete")
|
vim.api.nvim_buf_set_option(buf, "bufhidden", "delete")
|
||||||
vim.api.nvim_win_set_buf(winid, buf)
|
vim.api.nvim_win_set_buf(winid, buf)
|
||||||
|
|
||||||
vim.fn.termopen(cmd)
|
vim.fn.termopen(cmd)
|
||||||
vim.api.nvim_command([[normal! G]])
|
vim.api.nvim_command([[normal! G]])
|
||||||
vim.api.nvim_command([[wincmd p]])
|
vim.api.nvim_command([[wincmd p]])
|
||||||
end
|
end
|
||||||
|
|
||||||
_G.focus_tests = function()
|
_G.focus_tests = function()
|
||||||
local cmd = _G._build_test_cmd()
|
local cmd = _G._build_test_cmd()
|
||||||
if cmd == nil then
|
if cmd == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local winid = _G._test_cmd_to_wins[cmd]
|
local winid = _G._test_cmd_to_wins[cmd]
|
||||||
if winid == nil or not vim.api.nvim_win_is_valid(winid) then
|
if winid == nil or not vim.api.nvim_win_is_valid(winid) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.fn.win_gotoid(winid)
|
vim.fn.win_gotoid(winid)
|
||||||
vim.api.nvim_command([[wincmd =]])
|
vim.api.nvim_command([[wincmd =]])
|
||||||
end
|
end
|
||||||
|
|
||||||
_G.close_tests = function()
|
_G.close_tests = function()
|
||||||
local current_winid = vim.api.nvim_get_current_win()
|
local current_winid = vim.api.nvim_get_current_win()
|
||||||
for _, winid in pairs(_G._test_cmd_to_wins) do
|
for _, winid in pairs(_G._test_cmd_to_wins) do
|
||||||
if current_winid == winid and vim.api.nvim_win_is_valid(winid) then
|
if current_winid == winid and vim.api.nvim_win_is_valid(winid) then
|
||||||
vim.api.nvim_win_close(winid, false)
|
vim.api.nvim_win_close(winid, false)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local cmd = _G._build_test_cmd()
|
local cmd = _G._build_test_cmd()
|
||||||
if cmd == nil then
|
if cmd == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local winid = _G._test_cmd_to_wins[cmd]
|
local winid = _G._test_cmd_to_wins[cmd]
|
||||||
if winid == nil or not vim.api.nvim_win_is_valid(winid) then
|
if winid == nil or not vim.api.nvim_win_is_valid(winid) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_win_close(winid, false)
|
vim.api.nvim_win_close(winid, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
_G.copy_test_cmd = function()
|
_G.copy_test_cmd = function()
|
||||||
local cmd = _G._build_test_cmd()
|
local cmd = _G._build_test_cmd()
|
||||||
if cmd == nil then
|
if cmd == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.fn.setreg("+", cmd)
|
vim.fn.setreg("+", cmd)
|
||||||
print("Copied: " .. cmd)
|
print("Copied: " .. cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_set_keymap("n", "<leader>cr", [[:lua _G.run_tests()<cr>]], { noremap = true, silent = true })
|
vim.api.nvim_set_keymap("n", "<leader>cr", [[:lua _G.run_tests()<cr>]], { noremap = true, silent = true })
|
||||||
|
|
2
zshrc
2
zshrc
|
@ -116,7 +116,7 @@ alias pg="pgrep -fa"
|
||||||
alias pk="pkill -fc"
|
alias pk="pkill -fc"
|
||||||
alias rez="source $HOME/.zshenv && source $ZDOTDIR/.zshrc"
|
alias rez="source $HOME/.zshenv && source $ZDOTDIR/.zshrc"
|
||||||
alias rgo="rg -g '*.go' -g '!vendor/'"
|
alias rgo="rg -g '*.go' -g '!vendor/'"
|
||||||
alias rgs="rg -g '*.go' -g '*.rb' -g '!vendor/' -g '!*_test.go' -g '!*_spec.rb'"
|
alias rgs="rg -g '*.go' -g '*.rb' -g '!vendor/' -g '!*_test.go' -g '!*_spec.rb'" -g '!*/mocks/*' -g '!*_mock.go'
|
||||||
alias rgt="rg -g '*_test.go' -g '*_spec.rb' -g '!vendor/'"
|
alias rgt="rg -g '*_test.go' -g '*_spec.rb' -g '!vendor/'"
|
||||||
alias sc="systemctl"
|
alias sc="systemctl"
|
||||||
alias shc="shellcheck"
|
alias shc="shellcheck"
|
||||||
|
|
Loading…
Reference in New Issue