161 lines
4.7 KiB
Lua
161 lines
4.7 KiB
Lua
local hostname = "@HOSTNAME@"
|
|
|
|
local servers = {
|
|
clangd = {},
|
|
textlab = {},
|
|
lua_ls = {
|
|
settings = {
|
|
Lua = {
|
|
runtime = {
|
|
version = "LuaJIT",
|
|
},
|
|
diagnostics = {
|
|
globals = { "vim" },
|
|
},
|
|
workspace = {
|
|
library = vim.api.nvim_get_runtime_file("", true),
|
|
checkThirdParty = false,
|
|
},
|
|
telemetry = {
|
|
enable = false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
nixd = {
|
|
nixpkgs = {
|
|
expr = 'import (builtins.getFlake "/etc/nixos").inputs.nixpkgs {}',
|
|
},
|
|
formatting = { command = { "nixfmt" } },
|
|
options = {
|
|
nixos = {
|
|
expr = '(builtins.getFlake "/etc/nixos").nixosConfigurations.' .. hostname .. ".options",
|
|
},
|
|
home_manager = {
|
|
expr = '(builtins.getFlake "/etc/nixos").homeConfigurations.' .. hostname .. ".options",
|
|
},
|
|
},
|
|
},
|
|
phpactor = {},
|
|
zls = {
|
|
settings = {
|
|
zls = {
|
|
enable_build_on_save = true,
|
|
semantic_tokens = "partial",
|
|
},
|
|
},
|
|
},
|
|
css = {},
|
|
scss = {},
|
|
less = {},
|
|
blade = {},
|
|
html = { filetypes = { "html", "blade" } },
|
|
htmx = { filetypes = { "html", "blade" } },
|
|
gopls = {},
|
|
ols = {},
|
|
wgsl_analyzer = {},
|
|
}
|
|
for server, config in pairs(servers) do
|
|
vim.lsp.config(server, config)
|
|
vim.lsp.enable(server)
|
|
end
|
|
|
|
-- vim.api.nvim_create_autocmd("LspAttach", {
|
|
-- group = vim.api.nvim_create_augroup("UserConfigLsp", {}),
|
|
-- callback = function(ev)
|
|
vim.keymap.set("n", "gn", vim.lsp.buf.declaration, { desc = "go to declaration" })
|
|
vim.keymap.set("n", "ge", vim.lsp.buf.definition, { desc = "go to definition" })
|
|
-- vim.keymap.set("n", "gi", vim.lsp.buf.implementaion, { desc = "go to implementation" })
|
|
vim.keymap.set("n", "<leader>rr", vim.lsp.buf.rename, { desc = "lsp rename" })
|
|
vim.keymap.set("n", "<leader>ra", vim.lsp.buf.code_action, { desc = "code action" })
|
|
vim.keymap.set({ "n", "i" }, "<C-k>", vim.lsp.buf.signature_help, { desc = "signature help" })
|
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "references" })
|
|
-- end,
|
|
-- })
|
|
|
|
local leap = require("leap")
|
|
leap.opts.preview = function(ch0, ch1, ch2)
|
|
return not (ch1:match("%s") or (ch0:match("%a") and ch1:match("%a") and ch2:match("%a")))
|
|
end
|
|
leap.opts.equivalence_classes = {
|
|
" \t\r\n",
|
|
"([{",
|
|
")]}",
|
|
"'\"`",
|
|
}
|
|
vim.api.nvim_set_hl(0, "LeapBackdrop", { link = "Comment" })
|
|
|
|
do
|
|
-- Return an argument table for `leap()`, tailored for f/t-motions.
|
|
local function as_ft(key_specific_args)
|
|
local common_args = {
|
|
inputlen = 1,
|
|
inclusive = true,
|
|
-- To limit search scope to the current line:
|
|
-- pattern = function (pat) return '\\%.l'..pat end,
|
|
opts = {
|
|
labels = "", -- force autojump
|
|
safe_labels = vim.fn.mode(1):match("[no]") and "" or nil, -- [1]
|
|
},
|
|
}
|
|
return vim.tbl_deep_extend("keep", common_args, key_specific_args)
|
|
end
|
|
|
|
local clever = require("leap.user").with_traversal_keys -- [2]
|
|
local clever_f = clever("f", "F")
|
|
local clever_t = clever("t", "T")
|
|
|
|
for key, key_specific_args in pairs({
|
|
f = { opts = clever_f },
|
|
F = { backward = true, opts = clever_f },
|
|
t = { offset = -1, opts = clever_t },
|
|
T = { backward = true, offset = 1, opts = clever_t },
|
|
}) do
|
|
vim.keymap.set({ "n", "x", "o" }, key, function()
|
|
require("leap").leap(as_ft(key_specific_args))
|
|
end)
|
|
end
|
|
end
|
|
|
|
vim.api.nvim_create_autocmd("CmdlineLeave", {
|
|
group = vim.api.nvim_create_augroup("LeapOnSearch", {}),
|
|
callback = function()
|
|
local ev = vim.v.event
|
|
local is_search_cmd = (ev.cmdtype == "/") or (ev.cmdtype == "?")
|
|
local cnt = vim.fn.searchcount().total
|
|
if is_search_cmd and not ev.abort and (cnt > 1) then
|
|
-- Allow CmdLineLeave-related chores to be completed before
|
|
-- invoking Leap.
|
|
vim.schedule(function()
|
|
-- We want "safe" labels, but no auto-jump (as the search
|
|
-- command already does that), so just use `safe_labels`
|
|
-- as `labels`, with n/N removed.
|
|
local labels = require("leap").opts.safe_labels:gsub("[nN]", "")
|
|
-- For `pattern` search, we never need to adjust conceallevel
|
|
-- (no user input). We cannot merge `nil` from a table, but
|
|
-- using the option's current value has the same effect.
|
|
local vim_opts = { ["wo.conceallevel"] = vim.wo.conceallevel }
|
|
require("leap").leap({
|
|
pattern = vim.fn.getreg("/"), -- last search pattern
|
|
windows = { vim.fn.win_getid() },
|
|
opts = { safe_labels = "", labels = labels, vim_opts = vim_opts },
|
|
})
|
|
end)
|
|
end
|
|
end,
|
|
})
|
|
|
|
vim.keymap.set({ "n", "x", "o" }, "s", "<Plug>(leap)", { desc = "leap" })
|
|
vim.keymap.set({ "n", "x", "o" }, "S", "<Plug>(leap-from-window)", { desc = "leap across window" })
|
|
|
|
require("neotest").setup({
|
|
adapters = {
|
|
require("neotest-pest"),
|
|
},
|
|
})
|
|
vim.keymap.set("n", "<localleader>pn", function()
|
|
require("neotest").run.run()
|
|
end, { desc = "test nearest" })
|
|
vim.keymap.set("n", "<localleader>pe", function()
|
|
require("neotest").run.run(vim.fn.expand("%"))
|
|
end, { desc = "test file" })
|