Refactor back to a more modular configuration
This commit is contained in:
parent
19ea08a716
commit
2bedd41d83
178 changed files with 2245 additions and 1847 deletions
|
@ -0,0 +1,7 @@
|
|||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
desc = "Highlight when yanking (copying) text",
|
||||
group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }),
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
})
|
|
@ -0,0 +1,25 @@
|
|||
local status_ok, catppuccin = pcall(require, "catppuccin")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
catppuccin.setup {
|
||||
flavour = "macchiato",
|
||||
integrations = {
|
||||
cmp = true,
|
||||
gitsigns = true,
|
||||
mini = {
|
||||
enabled = true,
|
||||
indentscope_color = "",
|
||||
},
|
||||
native_lsp = {
|
||||
enabled = true,
|
||||
},
|
||||
telescope = true,
|
||||
treesitter = true,
|
||||
},
|
||||
term_colors = true,
|
||||
transparent_background = true,
|
||||
}
|
||||
|
||||
vim.cmd.colorscheme "catppuccin"
|
19
modules/home-manager/coding/neovim/config/plugin/comment.lua
Normal file
19
modules/home-manager/coding/neovim/config/plugin/comment.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
local status_ok, comment = pcall(require, "Comment")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
comment.setup {
|
||||
padding = true,
|
||||
|
||||
opleader = {
|
||||
line = "gc",
|
||||
block = "gb",
|
||||
},
|
||||
|
||||
mappings = {
|
||||
basic = true,
|
||||
extra = true,
|
||||
extended = false,
|
||||
},
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
local cmp = require "cmp"
|
||||
local ls = require "luasnip"
|
||||
|
||||
vim.opt.shortmess:append "c"
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
ls.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
["<C-e>"] = cmp.mapping.close(),
|
||||
|
||||
["<C-h>"] = cmp.mapping(function()
|
||||
if ls.locally_jumpable(-1) then
|
||||
ls.jump(-1)
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<C-l>"] = cmp.mapping(function()
|
||||
if ls.expand_or_locally_jumpable() then
|
||||
ls.expand_or_jump()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<C-y>"] = cmp.mapping.confirm { select = true },
|
||||
["<tab>"] = cmp.config.disable,
|
||||
},
|
||||
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "nvim_lua" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "calc" },
|
||||
},
|
||||
|
||||
sorting = {
|
||||
comparators = {
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.exact,
|
||||
cmp.config.compare.score,
|
||||
cmp.config.compare.kind,
|
||||
cmp.config.compare.sort_text,
|
||||
cmp.config.compare.length,
|
||||
cmp.config.compare.order,
|
||||
},
|
||||
},
|
||||
|
||||
formatting = {
|
||||
format = require("lspkind").cmp_format {
|
||||
with_text = true,
|
||||
menu = {
|
||||
buffer = "[buf]",
|
||||
cmp_tabnine = "[tn]",
|
||||
luasnip = "[snip]",
|
||||
nvim_lsp = "[lsp]",
|
||||
nvim_lua = "[lua]",
|
||||
path = "[path]",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
experimental = {
|
||||
native_menu = false,
|
||||
},
|
||||
}
|
||||
|
||||
cmp.setup.filetype({ "mysql", "sql" }, {
|
||||
sources = {
|
||||
{ name = "vim-dadbod-completion" },
|
||||
{ name = "buffer" },
|
||||
},
|
||||
})
|
46
modules/home-manager/coding/neovim/config/plugin/conform.lua
Normal file
46
modules/home-manager/coding/neovim/config/plugin/conform.lua
Normal file
|
@ -0,0 +1,46 @@
|
|||
local conform = require "conform"
|
||||
|
||||
conform.setup {
|
||||
formatters_by_ft = {
|
||||
bash = { "shellcheck" },
|
||||
go = { "gofmt" },
|
||||
javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
just = { "just" },
|
||||
lua = { "stylua" },
|
||||
nix = { "nixfmt" },
|
||||
php = { "php_cs_fixer", "phpcbf", stop_after_first = true },
|
||||
terraform = { "terraform_fmt" },
|
||||
yaml = { "yamlfmt" },
|
||||
},
|
||||
|
||||
format_on_save = function(bufnr)
|
||||
-- Disable with a global or buffer-local variable.
|
||||
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
|
||||
return
|
||||
end
|
||||
|
||||
return {
|
||||
lsp_fallback = false,
|
||||
quiet = true,
|
||||
}
|
||||
end,
|
||||
}
|
||||
|
||||
vim.api.nvim_create_user_command("FormatDisable", function(args)
|
||||
if args.bang then
|
||||
-- FormatDisable! will disable formatting just for this buffer
|
||||
vim.b.disable_autoformat = true
|
||||
else
|
||||
vim.g.disable_autoformat = true
|
||||
end
|
||||
end, {
|
||||
desc = "Disable autoformat-on-save",
|
||||
bang = true,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("FormatEnable", function()
|
||||
vim.b.disable_autoformat = false
|
||||
vim.g.disable_autoformat = false
|
||||
end, {
|
||||
desc = "Re-enable autoformat-on-save",
|
||||
})
|
69
modules/home-manager/coding/neovim/config/plugin/dap.lua
Normal file
69
modules/home-manager/coding/neovim/config/plugin/dap.lua
Normal file
|
@ -0,0 +1,69 @@
|
|||
local dap = require "dap"
|
||||
local ui = require "dapui"
|
||||
|
||||
dap.adapters.php = {
|
||||
type = "executable",
|
||||
command = "node",
|
||||
args = { os.getenv "HOME" .. "/build/vscode-php-debug/out/phpDebug.js" },
|
||||
}
|
||||
|
||||
dap.configurations.php = {
|
||||
{
|
||||
type = "php",
|
||||
request = "launch",
|
||||
name = "Listen for Xdebug",
|
||||
port = 9003,
|
||||
pathMappings = {
|
||||
["/app"] = "${workspaceFolder}",
|
||||
["/var/www/html"] = "${workspaceFolder}",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
dap.listeners.after.event_initialized["ui_config"] = function()
|
||||
ui.open()
|
||||
end
|
||||
|
||||
dap.listeners.before.event_terminated["ui_config"] = function()
|
||||
ui.close()
|
||||
end
|
||||
|
||||
dap.listeners.before.event_exited["ui_config"] = function()
|
||||
ui.close()
|
||||
end
|
||||
|
||||
ui.setup {
|
||||
layouts = {
|
||||
{
|
||||
elements = {
|
||||
{ id = "scopes", size = 0.25 },
|
||||
"breakpoints",
|
||||
"stacks",
|
||||
"watches",
|
||||
},
|
||||
size = 40, -- 40 columns
|
||||
position = "right",
|
||||
},
|
||||
{
|
||||
elements = {
|
||||
"repl",
|
||||
"console",
|
||||
},
|
||||
size = 0.25, -- 25% of total lines
|
||||
position = "bottom",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
require("nvim-dap-virtual-text").setup {
|
||||
commented = true,
|
||||
}
|
||||
|
||||
vim.keymap.set("n", "<leader>b", dap.toggle_breakpoint)
|
||||
vim.keymap.set("n", "<leader>gb", dap.run_to_cursor)
|
||||
|
||||
vim.keymap.set("n", "<F1>", dap.continue)
|
||||
vim.keymap.set("n", "<F2>", dap.step_into)
|
||||
vim.keymap.set("n", "<F3>", dap.step_over)
|
||||
vim.keymap.set("n", "<F4>", dap.step_out)
|
||||
vim.keymap.set("n", "<F5>", dap.step_back)
|
|
@ -0,0 +1,54 @@
|
|||
vim.fn["edit_alternate#rule#add"]("php", function(filename)
|
||||
if filename:find "Test.php$" then
|
||||
filename = filename:gsub("Test.php$", ".php")
|
||||
|
||||
if filename:find "tests/src/" then
|
||||
-- Drupal tests. Remove the `src/{type}` from the path.
|
||||
return filename:gsub("tests/src/(.-)/", "src/")
|
||||
else
|
||||
return filename:gsub("tests/", "src/")
|
||||
end
|
||||
else
|
||||
filename = filename:gsub(".php$", "Test.php")
|
||||
|
||||
if filename:find "modules/custom" then
|
||||
-- Drupal test types.
|
||||
local test_types = { "Functional", "FunctionalJavaScript", "Kernel", "Unit" }
|
||||
|
||||
for _, test_type in ipairs(test_types) do
|
||||
local filename_with_test_type = filename:gsub("src/", string.format("tests/src/%s/", test_type))
|
||||
|
||||
-- Return the first matching test file that exists.
|
||||
if vim.fn.filereadable(filename_with_test_type) == 1 then
|
||||
return filename_with_test_type
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
if vim.fn.filereadable "composer.json" == 1 then
|
||||
vim.fn["edit_alternate#rule#add"]("json", function(filename)
|
||||
if filename:find "composer.json" then
|
||||
return (filename:gsub("%.json$", ".lock"))
|
||||
end
|
||||
end)
|
||||
|
||||
vim.fn["edit_alternate#rule#add"]("lock", function(filename)
|
||||
if filename:find "composer.lock" then
|
||||
return (filename:gsub("%.lock$", ".json"))
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
if vim.fn.filereadable "fractal.config.js" == 1 then
|
||||
vim.fn["edit_alternate#rule#add"]("twig", function(filename)
|
||||
return (filename:gsub("%.twig$", ".config.yml"))
|
||||
end)
|
||||
|
||||
vim.fn["edit_alternate#rule#add"]("yml", function(filename)
|
||||
return (filename:gsub("%.config.yml$", ".twig"))
|
||||
end)
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>ea", "<CMD>EditAlternate<CR>", { silent = true })
|
|
@ -0,0 +1,15 @@
|
|||
vim.filetype.add {
|
||||
extension = {
|
||||
inc = "php",
|
||||
install = "php",
|
||||
module = "php",
|
||||
neon = "yaml",
|
||||
pcss = "scss",
|
||||
theme = "php",
|
||||
},
|
||||
|
||||
filename = {
|
||||
["composer.lock"] = "json",
|
||||
["phpstan.neon.dist"] = "yaml",
|
||||
},
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
vim.keymap.set("n", "<leader>gc", "<cmd>Git commit<cr><C-w>K")
|
||||
|
||||
-- Open the ":Git" window in its own buffer, not a split.
|
||||
vim.keymap.set("n", "<leader>gs", "<cmd>0Git<cr>")
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWinEnter", {
|
||||
pattern = "*",
|
||||
|
||||
callback = function()
|
||||
if vim.bo.ft ~= "fugitive" then
|
||||
return
|
||||
end
|
||||
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local opts = { buffer = bufnr, remap = false }
|
||||
|
||||
vim.keymap.set("n", "<leader>p", function()
|
||||
vim.cmd.Git "push"
|
||||
end, opts)
|
||||
|
||||
vim.keymap.set("n", "<leader>P", function()
|
||||
vim.cmd.Git { "pull", "--rebase" }
|
||||
end, opts)
|
||||
end,
|
||||
})
|
|
@ -0,0 +1,30 @@
|
|||
local gitsigns = require "gitsigns"
|
||||
|
||||
gitsigns.setup {
|
||||
linehl = false,
|
||||
numhl = true,
|
||||
}
|
||||
|
||||
local set = vim.keymap.set
|
||||
|
||||
set("n", "[h", "<cmd>Gitsigns prev_hunk<CR>")
|
||||
set("n", "]h", "<cmd>Gitsigns next_hunk<CR>")
|
||||
|
||||
set("n", "<leader>hR", gitsigns.reset_buffer)
|
||||
set("n", "<leader>hS", gitsigns.stage_buffer)
|
||||
set("n", "<leader>hb", gitsigns.blame_line)
|
||||
set("n", "<leader>hp", gitsigns.preview_hunk)
|
||||
set("n", "<leader>hr", gitsigns.reset_hunk)
|
||||
set("n", "<leader>hs", gitsigns.stage_hunk)
|
||||
set("n", "<leader>hu", gitsigns.undo_stage_hunk)
|
||||
|
||||
set("v", "<leader>hr", function()
|
||||
gitsigns.reset_hunk { vim.fn.line ".", vim.fn.line "v" }
|
||||
end)
|
||||
|
||||
set("v", "<leader>hs", function()
|
||||
gitsigns.stage_hunk { vim.fn.line ".", vim.fn.line "v" }
|
||||
end)
|
||||
|
||||
-- Text object.
|
||||
set({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
|
34
modules/home-manager/coding/neovim/config/plugin/harpoon.lua
Normal file
34
modules/home-manager/coding/neovim/config/plugin/harpoon.lua
Normal file
|
@ -0,0 +1,34 @@
|
|||
local harpoon = require "harpoon"
|
||||
|
||||
harpoon:setup()
|
||||
|
||||
vim.keymap.set("n", "<leader>a", function()
|
||||
harpoon:list():add()
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<C-e>", function()
|
||||
harpoon.ui:toggle_quick_menu(harpoon:list())
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<C-h>", function()
|
||||
harpoon:list():select(1)
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<C-j>", function()
|
||||
harpoon:list():select(2)
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<C-k>", function()
|
||||
harpoon:list():select(3)
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<C-l>", function()
|
||||
harpoon:list():select(4)
|
||||
end)
|
||||
|
||||
-- Set <space>1..<space>5 be my shortcuts to moving to the files
|
||||
for _, idx in ipairs { 1, 2, 3, 4, 5 } do
|
||||
vim.keymap.set("n", string.format("<space>%d", idx), function()
|
||||
harpoon:list():select(idx)
|
||||
end)
|
||||
end
|
19
modules/home-manager/coding/neovim/config/plugin/lint.lua
Normal file
19
modules/home-manager/coding/neovim/config/plugin/lint.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
local lint = require "lint"
|
||||
|
||||
lint.linters_by_ft = {
|
||||
dockerfile = { "hadolint" },
|
||||
javascript = { "eslint_d" },
|
||||
json = { "jsonlint" },
|
||||
lua = { "luacheck" },
|
||||
markdown = { "markdownlint" },
|
||||
nix = { "nix" },
|
||||
php = { "php", "phpcs", "phpstan" },
|
||||
}
|
||||
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
|
||||
group = lint_augroup,
|
||||
callback = function()
|
||||
lint.try_lint()
|
||||
end,
|
||||
})
|
13
modules/home-manager/coding/neovim/config/plugin/mini.lua
Normal file
13
modules/home-manager/coding/neovim/config/plugin/mini.lua
Normal file
|
@ -0,0 +1,13 @@
|
|||
require("mini.ai").setup { n_lines = 500 }
|
||||
|
||||
require("mini.align").setup {}
|
||||
|
||||
require("mini.bracketed").setup {}
|
||||
|
||||
require("mini.move").setup {}
|
||||
|
||||
require("mini.operators").setup {}
|
||||
|
||||
require("mini.splitjoin").setup {}
|
||||
|
||||
require("mini.surround").setup {}
|
|
@ -0,0 +1,3 @@
|
|||
vim.keymap.set("n", "-", vim.cmd.Ex)
|
||||
|
||||
vim.g.netrw_banner = 0
|
|
@ -0,0 +1,2 @@
|
|||
vim.keymap.set("n", "<leader>pm", "<cmd>PhpactorContextMenu<CR>")
|
||||
vim.keymap.set("n", "<leader>pn", "<cmd>PhpactorClassNew<CR>")
|
|
@ -0,0 +1,12 @@
|
|||
local refactoring = require "refactoring"
|
||||
|
||||
-- TODO: add keymaps - https://github.com/ThePrimeagen/refactoring.nvim#configuration-for-refactoring-operations
|
||||
refactoring.setup {}
|
||||
|
||||
local opts = { silent = true }
|
||||
|
||||
vim.keymap.set("n", "<Leader>ri", "<Cmd>lua require 'refactoring'.refactor 'Inline Variable'<Cr>", opts)
|
||||
|
||||
vim.keymap.set("v", "<Leader>re", "<Esc><Cmd>lua require 'refactoring'.refactor 'Extract Function'<Cr>", opts)
|
||||
vim.keymap.set("v", "<Leader>ri", "<Esc><Cmd>lua require 'refactoring'.refactor 'Inline Variable'<Cr>", opts)
|
||||
vim.keymap.set("v", "<Leader>rv", "<Esc><Cmd>lua require 'refactoring'.refactor 'Extract Variable'<Cr>", opts)
|
|
@ -0,0 +1,32 @@
|
|||
local ls = require "luasnip"
|
||||
|
||||
ls.config.set_config {
|
||||
enable_autosnippets = true,
|
||||
history = true,
|
||||
updateevents = "TextChanged,TextChangedI",
|
||||
}
|
||||
|
||||
for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/opdavies/snippets/*.lua", true)) do
|
||||
loadfile(ft_path)()
|
||||
end
|
||||
|
||||
-- Expand the current item or just to the next item within the snippet.
|
||||
vim.keymap.set({ "i", "s" }, "<c-k>", function()
|
||||
if ls.expand_or_jumpable() then
|
||||
ls.expand_or_jump()
|
||||
end
|
||||
end, { silent = true })
|
||||
|
||||
-- Jump backwards.
|
||||
vim.keymap.set({ "i", "s" }, "<c-j>", function()
|
||||
if ls.jumpable(-1) then
|
||||
ls.jump(-1)
|
||||
end
|
||||
end, { silent = true })
|
||||
|
||||
-- Select within a list of options.
|
||||
vim.keymap.set("i", "<c-l>", function()
|
||||
if ls.choice_active() then
|
||||
ls.change_choice(1)
|
||||
end
|
||||
end)
|
|
@ -0,0 +1,64 @@
|
|||
local telescope = require "telescope"
|
||||
|
||||
telescope.setup {
|
||||
defaults = {
|
||||
layout_config = { prompt_position = "top" },
|
||||
path_display = { truncate = 1 },
|
||||
prompt_prefix = "$ ",
|
||||
sorting_strategy = "ascending",
|
||||
},
|
||||
|
||||
pickers = {
|
||||
lsp_references = {
|
||||
previewer = false,
|
||||
},
|
||||
},
|
||||
|
||||
extensions = {
|
||||
["ui-select"] = {
|
||||
require("telescope.themes").get_dropdown {},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
telescope.load_extension "fzf"
|
||||
telescope.load_extension "refactoring"
|
||||
telescope.load_extension "ui-select"
|
||||
|
||||
local builtin = require "telescope.builtin"
|
||||
|
||||
local M = {}
|
||||
|
||||
M.grep_bluecheese = function()
|
||||
builtin.live_grep { cwd = "web/sites/default/themes/bluecheese" }
|
||||
end
|
||||
|
||||
M.grep_drupalorg_theme = function()
|
||||
builtin.live_grep { cwd = "web/themes/contrib/drupalorg_theme" }
|
||||
end
|
||||
|
||||
M.search_all_files = function()
|
||||
builtin.find_files {
|
||||
find_command = { "rg", "--no-ignore", "--files" },
|
||||
}
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<space>/", builtin.current_buffer_fuzzy_find)
|
||||
vim.keymap.set("n", "<space>fb", builtin.buffers)
|
||||
vim.keymap.set("n", "<space>fd", builtin.find_files)
|
||||
vim.keymap.set("n", "<space>fh", builtin.help_tags)
|
||||
vim.keymap.set("n", "<space>fi", M.search_all_files)
|
||||
vim.keymap.set("n", "<space>fk", builtin.keymaps)
|
||||
vim.keymap.set("n", "<space>fr", builtin.lsp_references)
|
||||
vim.keymap.set("n", "<space>ft", builtin.git_files)
|
||||
|
||||
vim.keymap.set("n", "<space>ds", builtin.lsp_document_symbols)
|
||||
|
||||
vim.keymap.set("n", "<space>gw", builtin.grep_string)
|
||||
|
||||
vim.keymap.set("n", "<space>dgb", M.grep_bluecheese)
|
||||
vim.keymap.set("n", "<space>dgd", M.grep_drupalorg_theme)
|
||||
|
||||
vim.keymap.set({ "n", "v" }, "<space>gw", builtin.grep_string)
|
||||
|
||||
require("opdavies.telescope.multigrep").setup {}
|
133
modules/home-manager/coding/neovim/config/plugin/treesitter.lua
Normal file
133
modules/home-manager/coding/neovim/config/plugin/treesitter.lua
Normal file
|
@ -0,0 +1,133 @@
|
|||
local configs = require "nvim-treesitter.configs"
|
||||
local ts_repeat_move = require "nvim-treesitter.textobjects.repeatable_move"
|
||||
|
||||
configs.setup {
|
||||
autotag = {
|
||||
enable = true,
|
||||
},
|
||||
|
||||
context_commenting = {
|
||||
enable = true,
|
||||
},
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
|
||||
indent = {
|
||||
disable = { "yaml" },
|
||||
enable = true,
|
||||
},
|
||||
|
||||
matchup = {
|
||||
enable = true,
|
||||
},
|
||||
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true,
|
||||
|
||||
keymaps = {
|
||||
["a="] = { query = "@assignment.outer", desc = "Select outer part of an assignment" },
|
||||
["i="] = { query = "@assignment.inner", desc = "Select inner part of an assignment" },
|
||||
["l="] = { query = "@assignment.lhs", desc = "Select left hand side of an assignment" },
|
||||
["r="] = { query = "@assignment.rhs", desc = "Select right hand side of an assignment" },
|
||||
|
||||
["a:"] = { query = "@property.outer", desc = "Select outer part of an object property" },
|
||||
["i:"] = { query = "@property.inner", desc = "Select inner part of an object property" },
|
||||
["l:"] = { query = "@property.lhs", desc = "Select left part of an object property" },
|
||||
["r:"] = { query = "@property.rhs", desc = "Select right part of an object property" },
|
||||
|
||||
["aa"] = { query = "@parameter.outer", desc = "Select outer part of a parameter/argument" },
|
||||
["ia"] = { query = "@parameter.inner", desc = "Select inner part of a parameter/argument" },
|
||||
|
||||
["ac"] = { query = "@class.outer", desc = "Select outer part of a class" },
|
||||
["ic"] = { query = "@class.inner", desc = "Select inner part of a class" },
|
||||
|
||||
["af"] = { query = "@call.outer", desc = "Select outer part of a function call" },
|
||||
["if"] = { query = "@call.inner", desc = "Select inner part of a function call" },
|
||||
|
||||
["ai"] = { query = "@conditional.outer", desc = "Select outer part of a conditional" },
|
||||
["ii"] = { query = "@conditional.inner", desc = "Select inner part of a conditional" },
|
||||
|
||||
["al"] = { query = "@loop.outer", desc = "Select outer part of a loop" },
|
||||
["il"] = { query = "@loop.inner", desc = "Select inner part of a loop" },
|
||||
|
||||
["am"] = { query = "@function.outer", desc = "Select outer part of a method/function definition" },
|
||||
["im"] = { query = "@function.inner", desc = "Select inner part of a method/function definition" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
swap = {
|
||||
enable = true,
|
||||
|
||||
swap_next = {
|
||||
["<leader>na"] = "@parameter.inner", -- swap parameters/argument with next
|
||||
["<leader>n:"] = "@property.outer", -- swap object property with next
|
||||
["<leader>nm"] = "@function.outer", -- swap function with next
|
||||
},
|
||||
|
||||
swap_previous = {
|
||||
["<leader>pa"] = "@parameter.inner", -- swap parameters/argument with prev
|
||||
["<leader>p:"] = "@property.outer", -- swap object property with prev
|
||||
["<leader>pm"] = "@function.outer", -- swap function with previous
|
||||
},
|
||||
},
|
||||
|
||||
move = {
|
||||
enable = true,
|
||||
set_jumps = true, -- whether to set jumps in the jumplist
|
||||
|
||||
goto_next_start = {
|
||||
["]f"] = { query = "@call.outer", desc = "Next function call start" },
|
||||
["]m"] = { query = "@function.outer", desc = "Next method/function def start" },
|
||||
["]c"] = { query = "@class.outer", desc = "Next class start" },
|
||||
["]i"] = { query = "@conditional.outer", desc = "Next conditional start" },
|
||||
["]l"] = { query = "@loop.outer", desc = "Next loop start" },
|
||||
|
||||
["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" },
|
||||
["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" },
|
||||
},
|
||||
|
||||
goto_next_end = {
|
||||
["]F"] = { query = "@call.outer", desc = "Next function call end" },
|
||||
["]M"] = { query = "@function.outer", desc = "Next method/function def end" },
|
||||
["]C"] = { query = "@class.outer", desc = "Next class end" },
|
||||
["]I"] = { query = "@conditional.outer", desc = "Next conditional end" },
|
||||
["]L"] = { query = "@loop.outer", desc = "Next loop end" },
|
||||
},
|
||||
|
||||
goto_previous_start = {
|
||||
["[f"] = { query = "@call.outer", desc = "Prev function call start" },
|
||||
["[m"] = { query = "@function.outer", desc = "Prev method/function def start" },
|
||||
["[c"] = { query = "@class.outer", desc = "Prev class start" },
|
||||
["[i"] = { query = "@conditional.outer", desc = "Prev conditional start" },
|
||||
["[l"] = { query = "@loop.outer", desc = "Prev loop start" },
|
||||
},
|
||||
|
||||
goto_previous_end = {
|
||||
["[F"] = { query = "@call.outer", desc = "Prev function call end" },
|
||||
["[M"] = { query = "@function.outer", desc = "Prev method/function def end" },
|
||||
["[C"] = { query = "@class.outer", desc = "Prev class end" },
|
||||
["[I"] = { query = "@conditional.outer", desc = "Prev conditional end" },
|
||||
["[L"] = { query = "@loop.outer", desc = "Prev loop end" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local set = vim.keymap.set
|
||||
|
||||
set("n", "<leader>th", "<cmd>TSHighlightCapturesUnderCursor<CR>")
|
||||
set("n", "<leader>tp", "<cmd>TSPlaygroundToggle<CR>")
|
||||
|
||||
-- vim way: ; goes to the direction you were moving.
|
||||
set({ "n", "o", "x" }, ";", ts_repeat_move.repeat_last_move)
|
||||
set({ "n", "o", "x" }, ",", ts_repeat_move.repeat_last_move_opposite)
|
||||
|
||||
-- Optionally, make builtin f, F, t, T also repeatable with ; and ,
|
||||
set({ "n", "o", "x" }, "f", ts_repeat_move.builtin_f)
|
||||
set({ "n", "o", "x" }, "F", ts_repeat_move.builtin_F)
|
||||
set({ "n", "o", "x" }, "t", ts_repeat_move.builtin_t)
|
||||
set({ "n", "o", "x" }, "T", ts_repeat_move.builtin_T)
|
|
@ -0,0 +1 @@
|
|||
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
|
|
@ -0,0 +1,16 @@
|
|||
local set = vim.keymap.set
|
||||
|
||||
local options = {
|
||||
silent = true,
|
||||
}
|
||||
|
||||
set("n", "<leader>tf", ":TestFile<CR>", options)
|
||||
set("n", "<leader>tg", ":TestVisit<CR>", options)
|
||||
set("n", "<leader>tl", ":TestLast<CR>", options)
|
||||
set("n", "<leader>tn", ":TestNearest<CR>", options)
|
||||
set("n", "<leader>ts", ":TestSuite<CR>", options)
|
||||
|
||||
vim.cmd [[
|
||||
let test#php#phpunit#options = '--colors=always --testdox'
|
||||
let g:test#strategy = 'vimux'
|
||||
]]
|
Loading…
Add table
Add a link
Reference in a new issue