refactor(nvim): manage Neovim with Home Manager
This commit is contained in:
commit
a66d1c417d
58
after/plugin/colorscheme.lua
Normal file
58
after/plugin/colorscheme.lua
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
if not pcall(require, "colorbuddy") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.opt.termguicolors = true
|
||||||
|
|
||||||
|
require "colorbuddy".colorscheme "gruvbuddy"
|
||||||
|
require "colorizer".setup {}
|
||||||
|
|
||||||
|
local Group = require("colorbuddy.group").Group
|
||||||
|
local c = require("colorbuddy.color").colors
|
||||||
|
local g = require("colorbuddy.group").groups
|
||||||
|
local s = require("colorbuddy.style").styles
|
||||||
|
|
||||||
|
-- Global
|
||||||
|
-- Group.new("TSComment", c.none)
|
||||||
|
Group.new("TSInclude", nil)
|
||||||
|
Group.new("TSOperator", nil)
|
||||||
|
Group.new("TSPunctBracket", nil)
|
||||||
|
Group.new("TSPunctDelimiter", nil)
|
||||||
|
Group.new("WinSeparator", nil)
|
||||||
|
|
||||||
|
-- Lua
|
||||||
|
Group.new("luaTSConstant", c.blue)
|
||||||
|
Group.new("luaTSField", nil, nil)
|
||||||
|
Group.new("luaTSFuncBuiltin", nil)
|
||||||
|
Group.new("luaTSFunction", nil)
|
||||||
|
Group.new("luaTSKeyword", nil)
|
||||||
|
Group.new("luaTSKeywordFunction", c.violet)
|
||||||
|
Group.new("luaTSKeywordOperator", c.orange)
|
||||||
|
Group.new("luaTSKeywordReturn", nil)
|
||||||
|
Group.new("luaTSParameter", nil)
|
||||||
|
Group.new("luaTSPunctBracket", nil)
|
||||||
|
Group.new("luaTSString", c.blue)
|
||||||
|
Group.new("luaTSVariable", nil)
|
||||||
|
|
||||||
|
-- PHP
|
||||||
|
Group.new("phpTSInclude", nil)
|
||||||
|
Group.new("phpTSKeyword", nil)
|
||||||
|
Group.new("phpTSKeywordFunction", nil)
|
||||||
|
Group.new("phpTSMethod", c.blue)
|
||||||
|
Group.new("phpTSOperator", nil)
|
||||||
|
Group.new("phpTSVariableBuiltin", nil)
|
||||||
|
Group.new("phpTSNamespace", c.blue)
|
||||||
|
|
||||||
|
-- JavaScript
|
||||||
|
Group.new("javascriptTSConstructor", c.blue)
|
||||||
|
Group.new("javascriptTSException", c.red)
|
||||||
|
Group.new("javascriptTSFunction", c.none)
|
||||||
|
Group.new("javascriptTSMethod", nil)
|
||||||
|
Group.new("javascriptTSProperty", nil)
|
||||||
|
Group.new("javascriptTSVariable", c.blue)
|
||||||
|
|
||||||
|
-- TypeScript
|
||||||
|
Group.new("typescriptTSConditional", c.none)
|
||||||
|
Group.new("typescriptTSKeyword", c.none)
|
||||||
|
Group.new("typescriptTSProperty", c.violet)
|
||||||
|
Group.new("typescriptTSType", c.blue)
|
19
after/plugin/comment.lua
Normal file
19
after/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,
|
||||||
|
},
|
||||||
|
}
|
74
after/plugin/completion.lua
Normal file
74
after/plugin/completion.lua
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
local cmp_status_ok, cmp = pcall(require, "cmp")
|
||||||
|
if not cmp_status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local snip_status_ok, luasnip = pcall(require, "luasnip")
|
||||||
|
if not snip_status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.opt.shortmess:append "c"
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
luasnip.lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
mapping = cmp.mapping.preset.insert {
|
||||||
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-e>"] = cmp.mapping.close(),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<C-y>"] = cmp.mapping.confirm { select = true },
|
||||||
|
["<tab>"] = cmp.config.disable,
|
||||||
|
},
|
||||||
|
|
||||||
|
sources = {
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "nvim_lua" },
|
||||||
|
{ name = "cmp_tabnine" },
|
||||||
|
{ name = "path" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
{ name = "buffer", keyword_length = 5, max_item_count = 5 },
|
||||||
|
},
|
||||||
|
|
||||||
|
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 = {
|
||||||
|
ghost_text = false,
|
||||||
|
native_menu = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.cmd [[
|
||||||
|
augroup DadbodSql
|
||||||
|
au!
|
||||||
|
autocmd FileType sql,mysql,plsql lua require('cmp').setup.buffer { sources = { { name = 'vim-dadbod-completion' } } }
|
||||||
|
augroup END
|
||||||
|
]]
|
74
after/plugin/dap.lua
Normal file
74
after/plugin/dap.lua
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
local has_dap, dap = pcall(require, "dap")
|
||||||
|
if not has_dap then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local has_dap_ui, dapui = pcall(require, "dapui")
|
||||||
|
if not has_dap_ui then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
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 = {
|
||||||
|
["/var/www/html"] = "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||||
|
dapui.open()
|
||||||
|
end
|
||||||
|
|
||||||
|
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||||
|
dapui.close()
|
||||||
|
end
|
||||||
|
|
||||||
|
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||||
|
dapui.close()
|
||||||
|
end
|
||||||
|
|
||||||
|
require "dapui".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,
|
||||||
|
}
|
||||||
|
|
||||||
|
local nmap = require "opdavies.keymap".nmap
|
||||||
|
|
||||||
|
nmap { "<F12>", ":lua require'dap'.step_over()<cr>" }
|
||||||
|
nmap { "<F2>", ":lua require'dap'.step_into()<cr>" }
|
||||||
|
nmap { "<F3>", ":lua require'dap'.step_over()<cr>" }
|
||||||
|
nmap { "<F5>", ":lua require'dap'.continue()<cr>" }
|
||||||
|
nmap { "<leader>b", ":lua require'dap'.toggle_breakpoint()<cr>" }
|
52
after/plugin/dial.lua
Normal file
52
after/plugin/dial.lua
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
local status_ok, dial_config = pcall(require, "dial.config")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local augend = require "dial.augend"
|
||||||
|
|
||||||
|
dial_config.augends:register_group {
|
||||||
|
visual = {
|
||||||
|
augend.integer.alias.decimal,
|
||||||
|
augend.integer.alias.hex,
|
||||||
|
augend.date.alias["%Y/%m/%d"],
|
||||||
|
augend.constant.alias.alpha,
|
||||||
|
augend.constant.alias.Alpha,
|
||||||
|
},
|
||||||
|
|
||||||
|
mygroup = {
|
||||||
|
augend.constant.new {
|
||||||
|
elements = { "TRUE", "FALSE" },
|
||||||
|
word = true,
|
||||||
|
cyclic = true,
|
||||||
|
},
|
||||||
|
|
||||||
|
augend.constant.new {
|
||||||
|
elements = { "public", "protected", "private" },
|
||||||
|
word = true,
|
||||||
|
cyclic = true,
|
||||||
|
},
|
||||||
|
|
||||||
|
augend.constant.new {
|
||||||
|
elements = { "&&", "||" },
|
||||||
|
word = false,
|
||||||
|
cyclic = true,
|
||||||
|
},
|
||||||
|
|
||||||
|
augend.date.alias["%d/%m/%Y"],
|
||||||
|
augend.constant.alias.bool, -- boolean value (true <-> false)
|
||||||
|
augend.integer.alias.decimal,
|
||||||
|
augend.integer.alias.hex,
|
||||||
|
augend.semver.alias.semver
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local dial_map = require "dial.map"
|
||||||
|
|
||||||
|
local nmap = require "opdavies.keymap".nmap
|
||||||
|
local vmap = require "opdavies.keymap".vmap
|
||||||
|
|
||||||
|
nmap({ "<C-a>", dial_map.inc_normal "mygroup" })
|
||||||
|
nmap({ "<C-x>", dial_map.dec_normal "mygroup" })
|
||||||
|
vmap({ "<C-a>", dial_map.inc_normal "visual" })
|
||||||
|
vmap({ "<C-x>", dial_map.dec_normal "visual" })
|
6
after/plugin/fidget.lua
Normal file
6
after/plugin/fidget.lua
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
local status_ok, fidget = pcall(require, "fidget")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
fidget.setup {}
|
30
after/plugin/git.lua
Normal file
30
after/plugin/git.lua
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
local status_ok, neogit = pcall(require, "neogit")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
neogit.setup {
|
||||||
|
disable_commit_confirmation = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
local nmap = require("opdavies.keymap").nmap
|
||||||
|
|
||||||
|
nmap {
|
||||||
|
"<leader>gc",
|
||||||
|
function()
|
||||||
|
neogit.open { "commit" }
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
nmap {
|
||||||
|
"<leader>gl",
|
||||||
|
function()
|
||||||
|
neogit.open { "log" }
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
nmap {
|
||||||
|
"<leader>gp",
|
||||||
|
function()
|
||||||
|
neogit.open { "push" }
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
nmap { "<leader>gs", neogit.open }
|
31
after/plugin/gitsigns.lua
Normal file
31
after/plugin/gitsigns.lua
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
local colorbuddy_status_ok, colorbuddy = pcall(require, "colorbuddy")
|
||||||
|
if not colorbuddy_status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local gitsigns_status_ok, gitsigns = pcall(require, "gitsigns")
|
||||||
|
if not gitsigns_status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local c = require("colorbuddy.color").colors
|
||||||
|
local Group = require("colorbuddy.group").Group
|
||||||
|
|
||||||
|
Group.new("GitSignsAdd", c.green)
|
||||||
|
Group.new("GitSignsChange", c.yellow)
|
||||||
|
Group.new("GitSignsDelete", c.red)
|
||||||
|
|
||||||
|
gitsigns.setup {
|
||||||
|
linehl = false,
|
||||||
|
numhl = true,
|
||||||
|
|
||||||
|
signs = {
|
||||||
|
add = { hl = "GitSignsAdd", text = "│", numhl = "GitSignsAddNr" },
|
||||||
|
change = { hl = "GitSignsChange", text = "│", numhl = "GitSignsChangeNr" },
|
||||||
|
delete = { hl = "GitSignsDelete", text = "_", numhl = "GitSignsDeleteNr" },
|
||||||
|
topdelete = { hl = "GitSignsDelete", text = "‾", numhl = "GitSignsDeleteNr" },
|
||||||
|
changedelete = { hl = "GitSignsDelete", text = "~", numhl = "GitSignsChangeNr" },
|
||||||
|
},
|
||||||
|
|
||||||
|
word_diff = false,
|
||||||
|
}
|
20
after/plugin/harpoon.lua
Normal file
20
after/plugin/harpoon.lua
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
local status_ok, harpoon = pcall(require, "harpoon")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local nmap = require("opdavies.keymap").nmap
|
||||||
|
|
||||||
|
harpoon.setup {}
|
||||||
|
|
||||||
|
nmap { "<M-h><M-l>", require("harpoon.ui").toggle_quick_menu }
|
||||||
|
nmap { "<M-h><M-m>", require("harpoon.mark").add_file }
|
||||||
|
|
||||||
|
for i = 1, 5 do
|
||||||
|
nmap {
|
||||||
|
string.format("<space>%s", i),
|
||||||
|
function()
|
||||||
|
require("harpoon.ui").nav_file(i)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
18
after/plugin/indent-blankline.lua
Normal file
18
after/plugin/indent-blankline.lua
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
local status_ok, indent_blankline = pcall(require, "indent_blankline")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.opt.list = true
|
||||||
|
vim.opt.listchars = {
|
||||||
|
eol = "↴",
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.cmd [[highlight IndentBlanklineIndent1 guifg=#555555 gui=nocombine]]
|
||||||
|
|
||||||
|
indent_blankline.setup {
|
||||||
|
char_highlight_list = {
|
||||||
|
"IndentBlanklineIndent1",
|
||||||
|
},
|
||||||
|
show_end_of_line = true,
|
||||||
|
}
|
67
after/plugin/lir.lua
Normal file
67
after/plugin/lir.lua
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
local has_lir, lir = pcall(require, "lir")
|
||||||
|
if not has_lir then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local actions = require "lir.actions"
|
||||||
|
local clipboard_actions = require "lir.clipboard.actions"
|
||||||
|
local mark_actions = require "lir.mark.actions"
|
||||||
|
|
||||||
|
lir.setup {
|
||||||
|
hide_cursor = true,
|
||||||
|
show_hidden_files = true,
|
||||||
|
devicons_enable = true,
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
["l"] = actions.edit,
|
||||||
|
["<C-s>"] = actions.split,
|
||||||
|
["<C-v>"] = actions.vsplit,
|
||||||
|
["<C-t>"] = actions.tabedit,
|
||||||
|
|
||||||
|
["h"] = actions.up,
|
||||||
|
["q"] = actions.quit,
|
||||||
|
|
||||||
|
["K"] = actions.mkdir,
|
||||||
|
["N"] = actions.newfile,
|
||||||
|
["R"] = actions.rename,
|
||||||
|
["@"] = actions.cd,
|
||||||
|
["Y"] = actions.yank_path,
|
||||||
|
["."] = actions.toggle_show_hidden,
|
||||||
|
["D"] = actions.delete,
|
||||||
|
|
||||||
|
["J"] = function()
|
||||||
|
mark_actions.toggle_mark()
|
||||||
|
vim.cmd "normal! j"
|
||||||
|
end,
|
||||||
|
|
||||||
|
["C"] = clipboard_actions.copy,
|
||||||
|
["X"] = clipboard_actions.cut,
|
||||||
|
["P"] = clipboard_actions.paste,
|
||||||
|
},
|
||||||
|
|
||||||
|
float = {
|
||||||
|
winblend = 0,
|
||||||
|
curdir_window = {
|
||||||
|
enable = false,
|
||||||
|
highlight_dirname = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
on_init = function()
|
||||||
|
-- use visual mode
|
||||||
|
vim.api.nvim_buf_set_keymap(
|
||||||
|
0,
|
||||||
|
"x",
|
||||||
|
"J",
|
||||||
|
':<C-u>lua require"lir.mark.actions".toggle_mark("v")<CR>',
|
||||||
|
{ noremap = true, silent = true }
|
||||||
|
)
|
||||||
|
|
||||||
|
-- echo cwd
|
||||||
|
vim.api.nvim_echo({ { vim.fn.expand "%:p", "Normal" } }, false, {})
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
require("lir.git_status").setup {
|
||||||
|
show_ignored = false,
|
||||||
|
}
|
6
after/plugin/lualine.lua
Normal file
6
after/plugin/lualine.lua
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
local status_ok, lualine = pcall(require, "lualine")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
lualine.setup {}
|
95
after/plugin/luasnip.lua
Normal file
95
after/plugin/luasnip.lua
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
if not pcall(require, "luasnip") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local api = vim.api
|
||||||
|
local fn = vim.fn
|
||||||
|
|
||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
local snippet = ls.snippet
|
||||||
|
local t = ls.text_node
|
||||||
|
|
||||||
|
local shortcut = function(val)
|
||||||
|
if type(val) == "string" then
|
||||||
|
return { t { val }, i(0) }
|
||||||
|
end
|
||||||
|
|
||||||
|
if type(val) == "table" then
|
||||||
|
for k, v in ipairs(val) do
|
||||||
|
if type(v) == "string" then
|
||||||
|
val[k] = t { v }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return val
|
||||||
|
end
|
||||||
|
|
||||||
|
local make = function(tbl)
|
||||||
|
local result = {}
|
||||||
|
for k, v in pairs(tbl) do
|
||||||
|
table.insert(result, (snippet({ trig = k, desc = v.desc }, shortcut(v))))
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
local snippets = {}
|
||||||
|
|
||||||
|
for _, ft_path in ipairs(api.nvim_get_runtime_file("lua/opdavies/snippets/ft/*.lua", true)) do
|
||||||
|
local ft = fn.fnamemodify(ft_path, ":t:r")
|
||||||
|
snippets[ft] = make(loadfile(ft_path)())
|
||||||
|
|
||||||
|
ls.add_snippets(ft, snippets[ft])
|
||||||
|
end
|
||||||
|
|
||||||
|
ls.add_snippets("js", snippets.javascript)
|
||||||
|
ls.add_snippets("typescript", snippets.javascript)
|
||||||
|
ls.add_snippets("vue", snippets.javascript)
|
||||||
|
|
||||||
|
ls.config.set_config {
|
||||||
|
enable_autosnippets = true,
|
||||||
|
history = true,
|
||||||
|
updateevents = "TextChanged,TextChangedI",
|
||||||
|
}
|
||||||
|
|
||||||
|
local imap = require("opdavies.keymap").imap
|
||||||
|
local map = require("opdavies.keymap").map
|
||||||
|
local nmap = require("opdavies.keymap").nmap
|
||||||
|
|
||||||
|
-- Expand the current item or just to the next item within the snippet.
|
||||||
|
map {
|
||||||
|
{ "i", "s" },
|
||||||
|
"<c-k>",
|
||||||
|
function()
|
||||||
|
if ls.expand_or_jumpable() then
|
||||||
|
ls.expand_or_jump()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
{ silent = true },
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Jump backwards.
|
||||||
|
map {
|
||||||
|
{ "i", "s" },
|
||||||
|
"<c-j>",
|
||||||
|
function()
|
||||||
|
if ls.jumpable(-1) then
|
||||||
|
ls.jump(-1)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
{ silent = true },
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Select within a list of options.
|
||||||
|
imap {
|
||||||
|
"<c-l>",
|
||||||
|
function()
|
||||||
|
if ls.choice_active() then
|
||||||
|
ls.change_choice(1)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
nmap { "<leader><leader>s", "<cmd>source ~/.config/nvim/after/plugin/luasnip.lua<CR>" }
|
1
after/plugin/markdown-preview.lua
Normal file
1
after/plugin/markdown-preview.lua
Normal file
|
@ -0,0 +1 @@
|
||||||
|
vim.g.mkdp_refresh_slow = 1
|
17
after/plugin/nvim-rest.lua
Normal file
17
after/plugin/nvim-rest.lua
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
local status_ok, rest_nvim = pcall(require, "rest-nvim")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local nmap = require("opdavies.keymap").nmap
|
||||||
|
|
||||||
|
-- Run the request.
|
||||||
|
nmap { "<leader>rr", "require('rest-nvim').run()" }
|
||||||
|
|
||||||
|
-- Preview the request.
|
||||||
|
nmap { "<leader>rp", "require('rest-nvim').run(true)" }
|
||||||
|
|
||||||
|
-- Re-run the last request.
|
||||||
|
nmap { "<leader>rl", "require('rest-nvim').last()" }
|
||||||
|
|
||||||
|
rest_nvim.setup()
|
18
after/plugin/refactoring.lua
Normal file
18
after/plugin/refactoring.lua
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
local status_ok, refactoring = pcall(require, "refactoring")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local nmap = require("opdavies.keymap").nmap
|
||||||
|
local vmap = require("opdavies.keymap").vmap
|
||||||
|
|
||||||
|
-- TODO: add keymaps - https://github.com/ThePrimeagen/refactoring.nvim#configuration-for-refactoring-operations
|
||||||
|
refactoring.setup {}
|
||||||
|
|
||||||
|
local opts = { silent = true }
|
||||||
|
|
||||||
|
nmap { "<Leader>ri", "<Cmd>lua require 'refactoring'.refactor 'Inline Variable'<Cr>", opts }
|
||||||
|
|
||||||
|
vmap { "<Leader>re", "<Esc><Cmd>lua require 'refactoring'.refactor 'Extract Function'<Cr>", opts }
|
||||||
|
vmap { "<Leader>ri", "<Esc><Cmd>lua require 'refactoring'.refactor 'Inline Variable'<Cr>", opts }
|
||||||
|
vmap { "<Leader>rv", "<Esc><Cmd>lua require 'refactoring'.refactor 'Extract Variable'<Cr>", opts }
|
3
after/plugin/seiya.lua
Normal file
3
after/plugin/seiya.lua
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
-- vim.g.seiya_auto_enable = 1
|
||||||
|
|
||||||
|
-- vim.g.seiya_target_groups = { "guibg" }
|
81
after/plugin/statusline.lua
Normal file
81
after/plugin/statusline.lua
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
local status_ok, el = pcall(require, "el")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local builtin = require "el.builtin"
|
||||||
|
local diagnostic = require "el.diagnostic"
|
||||||
|
local extensions = require "el.extensions"
|
||||||
|
local lsp_statusline = require "el.plugins.lsp_status"
|
||||||
|
local sections = require "el.sections"
|
||||||
|
local subscribe = require "el.subscribe"
|
||||||
|
|
||||||
|
local file_icon = subscribe.buf_autocmd("el_file_icon", "BufRead", function(_, buffer)
|
||||||
|
return extensions.file_icon(_, buffer)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local git_branch = subscribe.buf_autocmd("el_git_branch", "BufEnter", function(window, buffer)
|
||||||
|
local branch = extensions.git_branch(window, buffer)
|
||||||
|
if branch then
|
||||||
|
return " " .. extensions.git_icon() .. " " .. branch
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
local git_changes = subscribe.buf_autocmd("el_git_changes", "BufWritePost", function(window, buffer)
|
||||||
|
return extensions.git_changes(window, buffer)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local show_current_func = function(window, buffer)
|
||||||
|
if buffer.filetype == "lua" then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
return lsp_statusline.current_function(window, buffer)
|
||||||
|
end
|
||||||
|
|
||||||
|
local diagnostic_display = diagnostic.make_buffer()
|
||||||
|
|
||||||
|
el.setup {
|
||||||
|
generator = function(window, buffer)
|
||||||
|
local mode = extensions.gen_mode { format_string = " %s " }
|
||||||
|
|
||||||
|
local items = {
|
||||||
|
{ mode },
|
||||||
|
{ git_branch },
|
||||||
|
{ sections.split },
|
||||||
|
{ file_icon },
|
||||||
|
{ " " },
|
||||||
|
{ sections.maximum_width(builtin.make_responsive_file(140, 90), 0.40) },
|
||||||
|
{ sections.collapse_builtin { { " " }, { builtin.modified_flag } } },
|
||||||
|
{ sections.split },
|
||||||
|
{ diagnostic_display },
|
||||||
|
{ show_current_func },
|
||||||
|
{ git_changes },
|
||||||
|
{ "[" },
|
||||||
|
{ builtin.line_with_width(3) },
|
||||||
|
{ ":" },
|
||||||
|
{ builtin.column_with_width(2) },
|
||||||
|
{ "]" },
|
||||||
|
{
|
||||||
|
sections.collapse_builtin {
|
||||||
|
"[",
|
||||||
|
builtin.help_list,
|
||||||
|
builtin.readonly_list,
|
||||||
|
"]",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ builtin.filetype },
|
||||||
|
}
|
||||||
|
|
||||||
|
local add_item = function(result, item)
|
||||||
|
table.insert(result, item)
|
||||||
|
end
|
||||||
|
|
||||||
|
local result = {}
|
||||||
|
for _, item in ipairs(items) do
|
||||||
|
add_item(result, item)
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end,
|
||||||
|
}
|
9
after/plugin/terminal.vim
Normal file
9
after/plugin/terminal.vim
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
function! s:small_terminal() abort
|
||||||
|
new
|
||||||
|
wincmd J
|
||||||
|
call nvim_win_set_height(0, 12)
|
||||||
|
set winfixheight
|
||||||
|
term
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
nnoremap <leader>st :call <SID>small_terminal()<CR>
|
6
after/plugin/todo-comments.lua
Normal file
6
after/plugin/todo-comments.lua
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
local status_ok, todo_comments = pcall(require, "todo-comments")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
todo_comments.setup {}
|
72
after/plugin/treesitter.lua
Normal file
72
after/plugin/treesitter.lua
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
local has_configs, configs = pcall(require, "nvim-treesitter.configs")
|
||||||
|
if not has_configs then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local parser_install_dir = vim.fn.stdpath('data') .. "/site";
|
||||||
|
|
||||||
|
configs.setup {
|
||||||
|
context_commenting = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
ensure_installed = {
|
||||||
|
"bash",
|
||||||
|
"comment",
|
||||||
|
"css",
|
||||||
|
"dockerfile",
|
||||||
|
"go",
|
||||||
|
"html",
|
||||||
|
"javascript",
|
||||||
|
"json",
|
||||||
|
"lua",
|
||||||
|
"make",
|
||||||
|
"markdown",
|
||||||
|
"php",
|
||||||
|
"regex",
|
||||||
|
"rst",
|
||||||
|
"scss",
|
||||||
|
"typescript",
|
||||||
|
"vim",
|
||||||
|
"vue",
|
||||||
|
"yaml",
|
||||||
|
},
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
indent = {
|
||||||
|
disable = { "yaml" },
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
matchup = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
textobjects = {
|
||||||
|
select = {
|
||||||
|
enable = true,
|
||||||
|
lookahead = true,
|
||||||
|
|
||||||
|
keymaps = {
|
||||||
|
["af"] = "@function.outer",
|
||||||
|
["if"] = "@function.inner",
|
||||||
|
["ac"] = "@class.outer",
|
||||||
|
["ic"] = "@class.inner",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
parser_install_dir = parser_install_dir,
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.opt.runtimepath:append(parser_install_dir)
|
||||||
|
|
||||||
|
local nmap = require("opdavies.keymap").nmap
|
||||||
|
|
||||||
|
nmap { "<leader>th", "<cmd>TSHighlightCapturesUnderCursor<CR>" }
|
||||||
|
nmap { "<leader>tp", "<cmd>TSPlaygroundToggle<CR>" }
|
||||||
|
|
||||||
|
local has_context, context = pcall(require, "treesitter-context")
|
||||||
|
if not has_context then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
context.setup { enable = true }
|
8
after/plugin/twilight.lua
Normal file
8
after/plugin/twilight.lua
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
local status_ok, twilight = pcall(require, "twilight")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
twilight.setup {
|
||||||
|
context = 2,
|
||||||
|
}
|
15
after/plugin/vim-test.lua
Normal file
15
after/plugin/vim-test.lua
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
local map = vim.api.nvim_set_keymap
|
||||||
|
|
||||||
|
local options = {
|
||||||
|
silent = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
map("n", "t<C-f>", ":TestFile<CR>", options)
|
||||||
|
map("n", "t<C-g>", ":TestVisit<CR>", options)
|
||||||
|
map("n", "t<C-l>", ":TestLast<CR>", options)
|
||||||
|
map("n", "t<C-n>", ":TestNearest<CR>", options)
|
||||||
|
map("n", "t<C-s>", ":TestSuite<CR>", options)
|
||||||
|
|
||||||
|
vim.g["test#echo_command"] = 0
|
||||||
|
vim.g["test#neovim#start_normal"] = 1
|
||||||
|
vim.g["test#strategy"] = "vimux"
|
25
after/plugin/zen-mode.lua
Normal file
25
after/plugin/zen-mode.lua
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
local status_ok, zen_mode = pcall(require, "zen-mode")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
zen_mode.setup {
|
||||||
|
window = {
|
||||||
|
backdrop = 0.95,
|
||||||
|
height = 1,
|
||||||
|
width = 80,
|
||||||
|
options = {
|
||||||
|
relativenumber = false,
|
||||||
|
number = false,
|
||||||
|
signcolumn = "no",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins = {
|
||||||
|
options = {
|
||||||
|
enabled = true,
|
||||||
|
ruler = false,
|
||||||
|
},
|
||||||
|
gitsigns = { enabled = true },
|
||||||
|
tmux = { enabled = true },
|
||||||
|
},
|
||||||
|
}
|
12
autoload/opdavies.vim
Normal file
12
autoload/opdavies.vim
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
if !exists('*opdavies#save_and_exec')
|
||||||
|
function! opdavies#save_and_exec() abort
|
||||||
|
if &filetype == 'vim'
|
||||||
|
:silent! write
|
||||||
|
:source %
|
||||||
|
elseif &filetype == 'lua'
|
||||||
|
:silent! write
|
||||||
|
:luafile %
|
||||||
|
endif
|
||||||
|
return
|
||||||
|
endfunction
|
||||||
|
endif
|
12
init.lua
Normal file
12
init.lua
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
pcall("require", impatient)
|
||||||
|
|
||||||
|
require "opdavies.globals"
|
||||||
|
|
||||||
|
require("opdavies.options").setup()
|
||||||
|
|
||||||
|
require "opdavies.plugins"
|
||||||
|
|
||||||
|
require "opdavies.lsp"
|
||||||
|
|
||||||
|
require "opdavies.telescope.setup"
|
||||||
|
require "opdavies.telescope.mappings"
|
13
lua/opdavies/globals.lua
Normal file
13
lua/opdavies/globals.lua
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
P = function(v)
|
||||||
|
print(vim.inspect(v))
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
|
||||||
|
RELOAD = function(...)
|
||||||
|
return require("plenary.reload").reload_module(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
R = function(name)
|
||||||
|
RELOAD(name)
|
||||||
|
return require(name)
|
||||||
|
end
|
23
lua/opdavies/keymap.lua
Normal file
23
lua/opdavies/keymap.lua
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
M.imap = function(tbl)
|
||||||
|
vim.keymap.set("i", tbl[1], tbl[2], tbl[3])
|
||||||
|
end
|
||||||
|
|
||||||
|
M.map = function(tbl)
|
||||||
|
vim.keymap.set(tbl[1], tbl[2], tbl[3], tbl[4] or {})
|
||||||
|
end
|
||||||
|
|
||||||
|
M.nmap = function(tbl)
|
||||||
|
vim.keymap.set("n", tbl[1], tbl[2], tbl[3])
|
||||||
|
end
|
||||||
|
|
||||||
|
M.vmap = function(tbl)
|
||||||
|
vim.keymap.set("v", tbl[1], tbl[2], tbl[3])
|
||||||
|
end
|
||||||
|
|
||||||
|
M.xmap = function(tbl)
|
||||||
|
vim.keymap.set("x", tbl[1], tbl[2], tbl[3])
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
167
lua/opdavies/lsp/init.lua
Normal file
167
lua/opdavies/lsp/init.lua
Normal file
|
@ -0,0 +1,167 @@
|
||||||
|
local has_lsp, lspconfig = pcall(require, "lspconfig")
|
||||||
|
if not has_lsp then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local nvim_status = require "lsp-status"
|
||||||
|
|
||||||
|
local imap = require("opdavies.keymap").imap
|
||||||
|
local nmap = require("opdavies.keymap").nmap
|
||||||
|
|
||||||
|
local telescope_mapper = require "opdavies.telescope.mappings"
|
||||||
|
|
||||||
|
local buf_nnoremap = function(opts)
|
||||||
|
opts.buffer = 0
|
||||||
|
nmap(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
local buf_inoremap = function(opts)
|
||||||
|
opts.buffer = 0
|
||||||
|
imap(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
local updated_capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
updated_capabilities = require("cmp_nvim_lsp").update_capabilities(updated_capabilities)
|
||||||
|
|
||||||
|
local custom_init = function(client)
|
||||||
|
client.config.flags = client.config.flags or {}
|
||||||
|
client.config.flags.allow_incremental_sync = true
|
||||||
|
end
|
||||||
|
|
||||||
|
local custom_attach = function(client)
|
||||||
|
local filetype = vim.api.nvim_buf_get_option(0, "filetype")
|
||||||
|
|
||||||
|
nvim_status.on_attach(client)
|
||||||
|
|
||||||
|
-- Keymaps
|
||||||
|
buf_inoremap { "<c-s>", vim.lsp.buf.signature_help }
|
||||||
|
|
||||||
|
buf_nnoremap { "<leader>ca", vim.lsp.buf.code_action }
|
||||||
|
buf_nnoremap { "<leader>dn", vim.diagnostic.goto_next }
|
||||||
|
buf_nnoremap { "<leader>dp", vim.diagnostic.goto_prev }
|
||||||
|
buf_nnoremap { "<leader>f", vim.lsp.buf.format }
|
||||||
|
buf_nnoremap { "<leader>rn", vim.lsp.buf.rename }
|
||||||
|
buf_nnoremap { "<leader>rr", "<cmd>LspRestart<cr>" }
|
||||||
|
buf_nnoremap { "K", vim.lsp.buf.hover }
|
||||||
|
buf_nnoremap { "gD", vim.lsp.buf.declaration }
|
||||||
|
buf_nnoremap { "gT", vim.lsp.buf.type_definition }
|
||||||
|
buf_nnoremap { "gd", vim.lsp.buf.definition }
|
||||||
|
buf_nnoremap { "gi", vim.lsp.buf.implementation }
|
||||||
|
|
||||||
|
if filetype ~= "lua" then
|
||||||
|
buf_nnoremap { "K", vim.lsp.buf.hover }
|
||||||
|
end
|
||||||
|
|
||||||
|
telescope_mapper("<leader>dl", "diagnostics", nil, true)
|
||||||
|
|
||||||
|
-- Set autocommands conditional on server_capabilities
|
||||||
|
if client.server_capabilities.document_highlight then
|
||||||
|
vim.cmd [[
|
||||||
|
augroup lsp_document_highlight
|
||||||
|
autocmd! * <buffer>
|
||||||
|
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
||||||
|
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||||
|
augroup END
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Attach any filetype specific options to the client
|
||||||
|
-- filetype_attach[filetype](client)
|
||||||
|
end
|
||||||
|
|
||||||
|
local servers = {
|
||||||
|
ansiblels = true,
|
||||||
|
bashls = true,
|
||||||
|
cssls = true,
|
||||||
|
gopls = true,
|
||||||
|
html = true,
|
||||||
|
-- intelephense = true
|
||||||
|
rnix = true,
|
||||||
|
tsserver = true,
|
||||||
|
vuels = true,
|
||||||
|
yamlls = true,
|
||||||
|
|
||||||
|
intelephense = {
|
||||||
|
filetypes = { "php", "module", "test", "inc" },
|
||||||
|
},
|
||||||
|
|
||||||
|
sumneko_lua = {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = {
|
||||||
|
globals = { "vim" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
tailwindcss = {
|
||||||
|
filetypes = {
|
||||||
|
-- html
|
||||||
|
"html",
|
||||||
|
"html.twig",
|
||||||
|
"php",
|
||||||
|
"twig",
|
||||||
|
|
||||||
|
-- js
|
||||||
|
"javascript",
|
||||||
|
"typescript",
|
||||||
|
|
||||||
|
-- mixed
|
||||||
|
"vue",
|
||||||
|
},
|
||||||
|
|
||||||
|
init_options = {
|
||||||
|
userLanguages = {
|
||||||
|
["html.twig"] = "html",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- tsserver = {
|
||||||
|
-- filetypes = {
|
||||||
|
-- "javascript",
|
||||||
|
-- "javascriptreact",
|
||||||
|
-- "javascript.jsx",
|
||||||
|
-- "typescript",
|
||||||
|
-- "typescriptreact",
|
||||||
|
-- "typescript.tsx",
|
||||||
|
-- "vue",
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
}
|
||||||
|
|
||||||
|
local setup_server = function(server, config)
|
||||||
|
if not config then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if type(config) ~= "table" then
|
||||||
|
config = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
config = vim.tbl_deep_extend("force", {
|
||||||
|
on_init = custom_init,
|
||||||
|
on_attach = custom_attach,
|
||||||
|
capabilities = updated_capabilities,
|
||||||
|
flags = {
|
||||||
|
debounce_text_changes = nil,
|
||||||
|
},
|
||||||
|
}, config)
|
||||||
|
|
||||||
|
lspconfig[server].setup(config)
|
||||||
|
end
|
||||||
|
|
||||||
|
for server, config in pairs(servers) do
|
||||||
|
setup_server(server, config)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.diagnostic.config {
|
||||||
|
signs = true,
|
||||||
|
underline = false,
|
||||||
|
update_in_insert = false,
|
||||||
|
virtual_text = { spacing = 2 },
|
||||||
|
}
|
||||||
|
|
||||||
|
require "opdavies.lsp.null-ls"
|
||||||
|
require "opdavies.lsp.signature"
|
36
lua/opdavies/lsp/null-ls.lua
Normal file
36
lua/opdavies/lsp/null-ls.lua
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
local status_ok, null_ls = pcall(require, "null-ls")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local lsp_formatting = function(bufnr)
|
||||||
|
vim.lsp.buf.format {
|
||||||
|
filter = function(client)
|
||||||
|
return client.name == "null-ls"
|
||||||
|
end,
|
||||||
|
bufnr = bufnr,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||||
|
|
||||||
|
local completion = null_ls.builtins.completion
|
||||||
|
local diagnostics = null_ls.builtins.diagnostics
|
||||||
|
local formatting = null_ls.builtins.formatting
|
||||||
|
|
||||||
|
null_ls.setup {
|
||||||
|
sources = {
|
||||||
|
formatting.phpcbf,
|
||||||
|
formatting.markdownlint,
|
||||||
|
formatting.prettier,
|
||||||
|
formatting.rustywind,
|
||||||
|
formatting.stylua,
|
||||||
|
|
||||||
|
diagnostics.eslint,
|
||||||
|
diagnostics.markdownlint,
|
||||||
|
diagnostics.php,
|
||||||
|
diagnostics.phpcs,
|
||||||
|
diagnostics.phpstan,
|
||||||
|
diagnostics.shellcheck,
|
||||||
|
},
|
||||||
|
}
|
6
lua/opdavies/lsp/signature.lua
Normal file
6
lua/opdavies/lsp/signature.lua
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
local status_ok, lsp_signature = pcall(require, "lsp_signature")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
lsp_signature.setup {}
|
172
lua/opdavies/options.lua
Normal file
172
lua/opdavies/options.lua
Normal file
|
@ -0,0 +1,172 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local function set_autocmd()
|
||||||
|
vim.cmd [[
|
||||||
|
autocmd BufRead,BufNewFile *.test set filetype=php
|
||||||
|
|
||||||
|
autocmd BufWritePost plugins.lua luafile %
|
||||||
|
autocmd BufWritePost plugins.lua PackerSync
|
||||||
|
|
||||||
|
autocmd FileType gitcommit highlight ColorColumn ctermbg=8
|
||||||
|
autocmd FileType gitcommit setlocal colorcolumn=50,72
|
||||||
|
autocmd FileType gitcommit setlocal spell
|
||||||
|
autocmd FileType gitcommit setlocal textwidth=72
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Automatically resize buffers when Vim is resized.
|
||||||
|
vim.api.nvim_create_autocmd("VimResized *", { command = ":wincmd =" })
|
||||||
|
|
||||||
|
-- Cursorline highlighting control.
|
||||||
|
-- Only have it on in the current buffer.
|
||||||
|
local group = vim.api.nvim_create_augroup("CursorLineControl", { clear = true })
|
||||||
|
local set_cursorline = function(event, value, pattern)
|
||||||
|
vim.api.nvim_create_autocmd(event, {
|
||||||
|
group = group,
|
||||||
|
pattern = pattern,
|
||||||
|
callback = function()
|
||||||
|
vim.opt_local.cursorline = value
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
set_cursorline("WinLeave", false)
|
||||||
|
set_cursorline("WinEnter", true)
|
||||||
|
set_cursorline("FileType", false, "TelescopePrompt")
|
||||||
|
end
|
||||||
|
|
||||||
|
local function set_filetypes()
|
||||||
|
vim.cmd [[
|
||||||
|
filetype indent on
|
||||||
|
filetype on
|
||||||
|
filetype plugin on
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
|
||||||
|
local function set_key_mappings()
|
||||||
|
local map = vim.api.nvim_set_keymap
|
||||||
|
|
||||||
|
local options = { noremap = true }
|
||||||
|
|
||||||
|
map("n", "<Leader>so", ":call opdavies#save_and_exec()<CR>", options)
|
||||||
|
|
||||||
|
-- Format paragraphs to an 80 character line length.
|
||||||
|
map("n", "<Leader>g", "gqap", options)
|
||||||
|
map("x", "<Leader>g", "gqa", options)
|
||||||
|
|
||||||
|
-- Make the current file executable
|
||||||
|
map("n", "<Leader>x", ":!chmod +x %<Cr>", options)
|
||||||
|
|
||||||
|
-- Yank from the current column to the end of the line
|
||||||
|
map("n", "Y", "yg$", options)
|
||||||
|
|
||||||
|
-- Keep things centred
|
||||||
|
map("n", "n", "nzzzv", options)
|
||||||
|
map("n", "N", "Nzzzv", options)
|
||||||
|
|
||||||
|
-- Remove arrow keys
|
||||||
|
map("v", "<down>", "<nop>", options)
|
||||||
|
map("v", "<left>", "<nop>", options)
|
||||||
|
map("v", "<right>", "<nop>", options)
|
||||||
|
map("v", "<up>", "<nop>", options)
|
||||||
|
|
||||||
|
-- Clears hlsearch after doing a search, otherwise just does normal <CR> stuff
|
||||||
|
vim.cmd [[ nnoremap <expr> <CR> {-> v:hlsearch ? ":nohl\<CR>" : "\<CR>"}() ]]
|
||||||
|
|
||||||
|
map("n", "<C-f>", ":silent !tmux neww tmux-sessioniser<CR>", { noremap = true, silent = true })
|
||||||
|
|
||||||
|
local keymap = require "opdavies.keymap"
|
||||||
|
local imap = keymap.imap
|
||||||
|
local nmap = keymap.nmap
|
||||||
|
local vmap = keymap.vmap
|
||||||
|
local xmap = keymap.xmap
|
||||||
|
|
||||||
|
-- Easy insertion of a trailing ; or , from insert mode
|
||||||
|
imap { ",,", "<Esc>A,<Esc>" }
|
||||||
|
imap { ";;", "<Esc>A;<Esc>" }
|
||||||
|
|
||||||
|
nmap { "ga", "<Plug>(EasyAlign)" }
|
||||||
|
xmap { "ga", "<Plug>(EasyAlign)" }
|
||||||
|
|
||||||
|
-- Focus on the current buffer.
|
||||||
|
nmap { "<leader>-", ":wincmd _<cr>:wincmd |<cr>", { noremap = true, silent = true } }
|
||||||
|
|
||||||
|
-- Automatically resize buffers.
|
||||||
|
nmap { "<leader>=", ":wincmd =<cr>", { noremap = true, silent = true } }
|
||||||
|
|
||||||
|
-- Move line(s) up and down.
|
||||||
|
local opts = { noremap = true, silent = true }
|
||||||
|
imap { "<M-j>", "<Esc>:m .+1<CR>==gi", opts }
|
||||||
|
imap { "<M-k>", "<Esc>:m .-2<CR>==gi", opts }
|
||||||
|
nmap { "<M-j>", ":m .+1<CR>==", opts }
|
||||||
|
nmap { "<M-k>", ":m .-2<CR>==", opts }
|
||||||
|
vmap { "<M-j>", ":m '>+1<CR>gv=gv", opts }
|
||||||
|
vmap { "<M-k>", ":m '<-2<CR>gv=gv", opts }
|
||||||
|
|
||||||
|
-- Move half a screen up or down and re-center.
|
||||||
|
nmap { "<C-d>", "<C-d>zz" }
|
||||||
|
nmap { "<C-u>", "<C-u>zz" }
|
||||||
|
end
|
||||||
|
|
||||||
|
local function set_highlights()
|
||||||
|
vim.cmd [[highlight Comment cterm=italic gui=italic]]
|
||||||
|
end
|
||||||
|
|
||||||
|
local function set_vim_g()
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
end
|
||||||
|
|
||||||
|
local function set_vim_o()
|
||||||
|
local settings = {
|
||||||
|
autoindent = true,
|
||||||
|
breakindent = true,
|
||||||
|
conceallevel = 0,
|
||||||
|
cursorline = true,
|
||||||
|
expandtab = true,
|
||||||
|
foldlevel = 1,
|
||||||
|
foldlevelstart = 99,
|
||||||
|
foldmethod = "indent",
|
||||||
|
formatoptions = "lm",
|
||||||
|
hidden = false,
|
||||||
|
linebreak = true,
|
||||||
|
mouse = "n",
|
||||||
|
number = true,
|
||||||
|
pumblend = 10,
|
||||||
|
pumheight = 10,
|
||||||
|
relativenumber = true,
|
||||||
|
scrolloff = 10,
|
||||||
|
shiftwidth = 2,
|
||||||
|
showmode = false,
|
||||||
|
smartindent = true,
|
||||||
|
softtabstop = 2,
|
||||||
|
splitbelow = true,
|
||||||
|
splitright = true,
|
||||||
|
swapfile = false,
|
||||||
|
syntax = "on",
|
||||||
|
tabstop = 2,
|
||||||
|
termguicolors = true,
|
||||||
|
textwidth = 0,
|
||||||
|
updatetime = 1000,
|
||||||
|
winbar = "%=%m %f",
|
||||||
|
wrap = false,
|
||||||
|
}
|
||||||
|
|
||||||
|
for key, value in pairs(settings) do
|
||||||
|
vim.o[key] = value
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.opt.clipboard:append "unnamedplus"
|
||||||
|
vim.opt.completeopt = { "menu", "menuone", "noselect" }
|
||||||
|
vim.opt.laststatus = 3
|
||||||
|
end
|
||||||
|
|
||||||
|
M.setup = function()
|
||||||
|
set_vim_g()
|
||||||
|
set_vim_o()
|
||||||
|
set_key_mappings()
|
||||||
|
set_autocmd()
|
||||||
|
set_filetypes()
|
||||||
|
set_highlights()
|
||||||
|
|
||||||
|
vim.g.snippets = "luasnip"
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
137
lua/opdavies/plugins.lua
Normal file
137
lua/opdavies/plugins.lua
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
local status_ok, packer = pcall(require, "packer")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
packer.init {
|
||||||
|
display = {
|
||||||
|
open_fn = function()
|
||||||
|
return require("packer.util").float {}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return packer.startup(function()
|
||||||
|
local use = packer.use
|
||||||
|
|
||||||
|
use "wbthomason/packer.nvim"
|
||||||
|
|
||||||
|
-- Tmux
|
||||||
|
use "preservim/vimux"
|
||||||
|
|
||||||
|
-- Utilities
|
||||||
|
use "aca/emmet-ls"
|
||||||
|
use "andymass/vim-matchup"
|
||||||
|
use "cakebaker/scss-syntax.vim"
|
||||||
|
use "christoomey/vim-sort-motion"
|
||||||
|
use "christoomey/vim-tmux-navigator"
|
||||||
|
use "editorconfig/editorconfig-vim"
|
||||||
|
use "folke/twilight.nvim"
|
||||||
|
use "folke/zen-mode.nvim"
|
||||||
|
use "icatalina/vim-case-change"
|
||||||
|
use "junegunn/vim-easy-align"
|
||||||
|
use "kazhala/close-buffers.nvim"
|
||||||
|
use "kyazdani42/nvim-web-devicons"
|
||||||
|
use "lewis6991/gitsigns.nvim"
|
||||||
|
use "lewis6991/impatient.nvim"
|
||||||
|
use "machakann/vim-highlightedyank"
|
||||||
|
use "miyakogi/seiya.vim"
|
||||||
|
use "mkitt/tabline.vim"
|
||||||
|
use "monaqa/dial.nvim"
|
||||||
|
use "norcalli/nvim-colorizer.lua"
|
||||||
|
use "numToStr/Comment.nvim"
|
||||||
|
use "nvim-lua/plenary.nvim"
|
||||||
|
use "nvim-lua/popup.nvim"
|
||||||
|
use "sheerun/vim-polyglot"
|
||||||
|
use "theprimeagen/git-worktree.nvim"
|
||||||
|
use "theprimeagen/refactoring.nvim"
|
||||||
|
use "tjdevries/express_line.nvim"
|
||||||
|
use "tpope/vim-abolish"
|
||||||
|
use "tpope/vim-repeat"
|
||||||
|
use "tpope/vim-surround"
|
||||||
|
use "vim-test/vim-test"
|
||||||
|
use { "mg979/vim-visual-multi", branch = "master" }
|
||||||
|
|
||||||
|
-- Themes
|
||||||
|
use {
|
||||||
|
"tjdevries/gruvbuddy.nvim",
|
||||||
|
requires = {
|
||||||
|
"tjdevries/colorbuddy.vim",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Navigation
|
||||||
|
use "ThePrimeagen/harpoon"
|
||||||
|
use "tamago324/lir-git-status.nvim"
|
||||||
|
use "tamago324/lir.nvim"
|
||||||
|
|
||||||
|
-- Treesitter
|
||||||
|
use "nvim-treesitter/playground"
|
||||||
|
use 'nvim-treesitter/nvim-treesitter-context'
|
||||||
|
use {
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
run = ":TSUpdate",
|
||||||
|
}
|
||||||
|
use "nvim-treesitter/nvim-treesitter-textobjects"
|
||||||
|
|
||||||
|
-- Completion
|
||||||
|
use {
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
requires = {
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
"hrsh7th/cmp-buffer",
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
"hrsh7th/cmp-path",
|
||||||
|
"onsails/lspkind-nvim",
|
||||||
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Snippets
|
||||||
|
use "L3MON4D3/LuaSnip"
|
||||||
|
use "rafamadriz/friendly-snippets"
|
||||||
|
|
||||||
|
-- LSP
|
||||||
|
use "jose-elias-alvarez/null-ls.nvim"
|
||||||
|
use "neovim/nvim-lspconfig"
|
||||||
|
use "nvim-lua/lsp-status.nvim"
|
||||||
|
|
||||||
|
-- Debugging
|
||||||
|
use "mfussenegger/nvim-dap"
|
||||||
|
use "nvim-telescope/telescope-dap.nvim"
|
||||||
|
use "rcarriga/nvim-dap-ui"
|
||||||
|
use "theHamsta/nvim-dap-virtual-text"
|
||||||
|
|
||||||
|
-- Telescope
|
||||||
|
use "nvim-telescope/telescope.nvim"
|
||||||
|
use "nvim-telescope/telescope-file-browser.nvim"
|
||||||
|
use { "nvim-telescope/telescope-fzf-native.nvim", run = "make" }
|
||||||
|
use { "nvim-telescope/telescope-ui-select.nvim" }
|
||||||
|
|
||||||
|
-- Git
|
||||||
|
use "TimUntersberger/neogit"
|
||||||
|
|
||||||
|
-- Databases
|
||||||
|
use "tpope/vim-dadbod"
|
||||||
|
use "kristijanhusak/vim-dadbod-completion"
|
||||||
|
use "kristijanhusak/vim-dadbod-ui"
|
||||||
|
|
||||||
|
-- HTTP client
|
||||||
|
use "rest-nvim/rest.nvim"
|
||||||
|
|
||||||
|
-- Text objects
|
||||||
|
use "kana/vim-textobj-indent"
|
||||||
|
use "kana/vim-textobj-user"
|
||||||
|
use "vim-scripts/argtextobj.vim"
|
||||||
|
use "wellle/targets.vim"
|
||||||
|
|
||||||
|
-- Markdown
|
||||||
|
use {
|
||||||
|
"iamcco/markdown-preview.nvim",
|
||||||
|
run = "cd app && npm install",
|
||||||
|
setup = function()
|
||||||
|
vim.g.mkdp_filetypes = { "markdown" }
|
||||||
|
end,
|
||||||
|
ft = { "markdown" },
|
||||||
|
}
|
||||||
|
end)
|
10
lua/opdavies/snippets/ft/javascript.lua
Normal file
10
lua/opdavies/snippets/ft/javascript.lua
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
local fmta = require("luasnip.extras.fmt").fmta
|
||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
local i = ls.insert_node
|
||||||
|
|
||||||
|
local M = {
|
||||||
|
log = fmta("console.log(<>);", { i(1, "value") }),
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
27
lua/opdavies/snippets/ft/lua.lua
Normal file
27
lua/opdavies/snippets/ft/lua.lua
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
|
local rep = require("luasnip.extras").rep
|
||||||
|
|
||||||
|
local f, i = ls.function_node, ls.insert_node
|
||||||
|
|
||||||
|
return {
|
||||||
|
pcall = fmt(
|
||||||
|
[[
|
||||||
|
local status_ok, {} = pcall(require, "{}")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
]],
|
||||||
|
{ i(1), rep(1) }
|
||||||
|
),
|
||||||
|
|
||||||
|
req = fmt([[local {} = require "{}"]], {
|
||||||
|
f(function(import_name)
|
||||||
|
local parts = vim.split(import_name[1][1], ".", true)
|
||||||
|
|
||||||
|
return parts[#parts] or ""
|
||||||
|
end, { 1 }),
|
||||||
|
i(1),
|
||||||
|
}),
|
||||||
|
}
|
18
lua/opdavies/snippets/ft/markdown.lua
Normal file
18
lua/opdavies/snippets/ft/markdown.lua
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
local i = ls.insert_node
|
||||||
|
|
||||||
|
local M = {
|
||||||
|
frontmatter = fmt(
|
||||||
|
[[
|
||||||
|
---
|
||||||
|
title: {}
|
||||||
|
---
|
||||||
|
{}
|
||||||
|
]],
|
||||||
|
{ i(1), i(0) }
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
87
lua/opdavies/snippets/ft/php.lua
Normal file
87
lua/opdavies/snippets/ft/php.lua
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
local fmta = require("luasnip.extras.fmt").fmta
|
||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
local c = ls.choice_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local i = ls.insert_node
|
||||||
|
local t = ls.text_node
|
||||||
|
|
||||||
|
local M = {
|
||||||
|
|
||||||
|
drupalclass = fmta(
|
||||||
|
[[
|
||||||
|
<<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace <>;
|
||||||
|
|
||||||
|
final class <> {
|
||||||
|
|
||||||
|
<>
|
||||||
|
|
||||||
|
}]],
|
||||||
|
{
|
||||||
|
f(function()
|
||||||
|
local filepath = vim.fn.expand "%:h"
|
||||||
|
local filepath_parts = vim.fn.split(filepath, "/")
|
||||||
|
|
||||||
|
if not vim.tbl_contains(filepath_parts, "src") then
|
||||||
|
return ""
|
||||||
|
end
|
||||||
|
|
||||||
|
local namespace_parts = { "Drupal" }
|
||||||
|
|
||||||
|
local is_test_file = vim.tbl_contains(filepath_parts, "tests")
|
||||||
|
if is_test_file then
|
||||||
|
table.insert(namespace_parts, "Tests")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Find and add the module name.
|
||||||
|
for k, v in ipairs(filepath_parts) do
|
||||||
|
if v == "src" then
|
||||||
|
if is_test_file then
|
||||||
|
table.insert(namespace_parts, filepath_parts[k - 2])
|
||||||
|
else
|
||||||
|
table.insert(namespace_parts, filepath_parts[k - 1])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Add the rest of the namespace.
|
||||||
|
local namespace = vim.split(filepath, "src/")
|
||||||
|
local final_part = (namespace[2] or ""):gsub("/", "\\")
|
||||||
|
table.insert(namespace_parts, final_part)
|
||||||
|
|
||||||
|
return table.concat(namespace_parts, "\\")
|
||||||
|
end),
|
||||||
|
f(function()
|
||||||
|
return vim.fn.expand "%:t:r"
|
||||||
|
end),
|
||||||
|
i(0),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
|
||||||
|
func = fmta("function <>(<>)<> {\n <>\n}<>", { i(1), i(2), i(3), i(4), i(0) }),
|
||||||
|
|
||||||
|
met = fmta(
|
||||||
|
[[
|
||||||
|
<> function <>(<>)<> {
|
||||||
|
<>
|
||||||
|
}<>
|
||||||
|
]],
|
||||||
|
{ c(1, { t "public", t "protected", t "private" }), i(2), i(3), i(4), i(5), i(0) }
|
||||||
|
),
|
||||||
|
|
||||||
|
test = fmta(
|
||||||
|
[[
|
||||||
|
/** @test */
|
||||||
|
public function <><>(): void {
|
||||||
|
<>
|
||||||
|
}<>
|
||||||
|
]],
|
||||||
|
{ c(1, { t "test", t "it", t "should" }), i(2), i(3), i(0) }
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
22
lua/opdavies/snippets/ft/rst.lua
Normal file
22
lua/opdavies/snippets/ft/rst.lua
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
local i = ls.insert_node
|
||||||
|
local f = ls.function_node
|
||||||
|
|
||||||
|
local fill_line = function(char)
|
||||||
|
return function()
|
||||||
|
local row = vim.api.nvim_win_get_cursor(0)[1]
|
||||||
|
local lines = vim.api.nvim_buf_get_lines(0, row - 2, row, false)
|
||||||
|
return string.rep(char, #lines[1])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local M = {
|
||||||
|
link = { ".. _", i(1), ":" },
|
||||||
|
|
||||||
|
head = f(fill_line "=", {}),
|
||||||
|
sub = f(fill_line "-", {}),
|
||||||
|
subsub = f(fill_line "^", {}),
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
139
lua/opdavies/telescope/init.lua
Normal file
139
lua/opdavies/telescope/init.lua
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
SHOULD_RELOAD_TELESCOPE = true
|
||||||
|
|
||||||
|
local reloader = function()
|
||||||
|
if SHOULD_RELOAD_TELESCOPE then
|
||||||
|
RELOAD "plenary"
|
||||||
|
RELOAD "telescope"
|
||||||
|
RELOAD "opdavies.telescope.setup"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local themes = require "telescope.themes"
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.current_buf()
|
||||||
|
local opts = {
|
||||||
|
sorting_strategy = "ascending",
|
||||||
|
previewer = false,
|
||||||
|
}
|
||||||
|
|
||||||
|
require("telescope.builtin").current_buffer_fuzzy_find(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
M.diagnostics = function()
|
||||||
|
local theme = require("telescope.themes").get_dropdown {
|
||||||
|
previewer = false,
|
||||||
|
}
|
||||||
|
|
||||||
|
require("telescope.builtin").diagnostics(theme)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.lsp_document_symbols()
|
||||||
|
local theme = require("telescope.themes").get_dropdown {
|
||||||
|
previewer = false,
|
||||||
|
}
|
||||||
|
|
||||||
|
require("telescope.builtin").lsp_document_symbols(theme)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.edit_neovim()
|
||||||
|
local opts = {
|
||||||
|
cwd = "~/.config/nvim",
|
||||||
|
find_command = { "rg", "--no-ignore", "--files", "--follow" },
|
||||||
|
path_display = { "shorten" },
|
||||||
|
prompt_title = "~ dotfiles ~",
|
||||||
|
no_ignore = true,
|
||||||
|
|
||||||
|
layout_strategy = "flex",
|
||||||
|
layout_config = {
|
||||||
|
height = 0.8,
|
||||||
|
prompt_position = "top",
|
||||||
|
width = 0.9,
|
||||||
|
|
||||||
|
horizontal = {
|
||||||
|
width = { padding = 0.15 },
|
||||||
|
},
|
||||||
|
vertical = {
|
||||||
|
preview_height = 0.75,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
require("telescope.builtin").find_files(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.edit_zsh()
|
||||||
|
local opts = {
|
||||||
|
cwd = "~/.config/zsh",
|
||||||
|
path_display = { "shorten" },
|
||||||
|
prompt_title = "~ zsh ~",
|
||||||
|
no_ignore = true,
|
||||||
|
|
||||||
|
layout_strategy = "flex",
|
||||||
|
layout_config = {
|
||||||
|
height = 0.8,
|
||||||
|
prompt_position = "top",
|
||||||
|
width = 0.9,
|
||||||
|
|
||||||
|
horizontal = {
|
||||||
|
width = { padding = 0.15 },
|
||||||
|
},
|
||||||
|
vertical = {
|
||||||
|
preview_height = 0.75,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
require("telescope.builtin").find_files(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.file_browser()
|
||||||
|
local opts = {
|
||||||
|
cwd = vim.fn.expand "%:p:h",
|
||||||
|
sorting_strategy = "ascending",
|
||||||
|
}
|
||||||
|
|
||||||
|
require("telescope").extensions.file_browser.file_browser(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.fd()
|
||||||
|
local opts = themes.get_ivy {
|
||||||
|
file_ignore_patterns = { ".git/" },
|
||||||
|
hidden = true,
|
||||||
|
no_ignore = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
require("telescope.builtin").find_files(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.git_files()
|
||||||
|
local opts = themes.get_ivy {
|
||||||
|
file_ignore_patterns = { ".git/", "vendor" },
|
||||||
|
hidden = true,
|
||||||
|
no_ignore = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
require("telescope.builtin").git_files(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.live_grep()
|
||||||
|
require("telescope.builtin").live_grep {
|
||||||
|
file_ignore_patterns = { ".git/" },
|
||||||
|
hidden = true,
|
||||||
|
no_ignore = true,
|
||||||
|
sorting_strategy = "ascending",
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable({}, {
|
||||||
|
__index = function(_, k)
|
||||||
|
reloader()
|
||||||
|
|
||||||
|
if M[k] then
|
||||||
|
return M[k]
|
||||||
|
else
|
||||||
|
return require("telescope.builtin")[k]
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
44
lua/opdavies/telescope/mappings.lua
Normal file
44
lua/opdavies/telescope/mappings.lua
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
TelescopeMapArgs = TelescopeMapArgs or {}
|
||||||
|
|
||||||
|
local telescope = require "telescope"
|
||||||
|
|
||||||
|
local telescope_mapper = function(key, f, options, buffer)
|
||||||
|
local map_key = vim.api.nvim_replace_termcodes(key .. f, true, true, true)
|
||||||
|
|
||||||
|
TelescopeMapArgs[map_key] = options or {}
|
||||||
|
|
||||||
|
local mode = "n"
|
||||||
|
local rhs = string.format("<cmd>lua R('opdavies.telescope')['%s'](TelescopeMapArgs['%s'])<CR>", f, map_key)
|
||||||
|
|
||||||
|
local map_options = {
|
||||||
|
noremap = true,
|
||||||
|
silent = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
if not buffer then
|
||||||
|
vim.api.nvim_set_keymap(mode, key, rhs, map_options)
|
||||||
|
else
|
||||||
|
vim.api.nvim_buf_set_keymap(0, mode, key, rhs, map_options)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
telescope_mapper("<leader>fb", "buffers")
|
||||||
|
telescope_mapper("<leader>fd", "fd")
|
||||||
|
telescope_mapper("<leader>fe", "file_browser")
|
||||||
|
telescope_mapper("<leader>ff", "current_buf")
|
||||||
|
telescope_mapper("<leader>fg", "git_files")
|
||||||
|
telescope_mapper("<leader>fh", "help_tags")
|
||||||
|
telescope_mapper("<leader>fl", "live_grep")
|
||||||
|
|
||||||
|
telescope_mapper("<leader>ds", "lsp_document_symbols")
|
||||||
|
telescope_mapper("<leader>dl", "diagnostics")
|
||||||
|
|
||||||
|
telescope_mapper("<leader>en", "edit_neovim")
|
||||||
|
telescope_mapper("<leader>ez", "edit_zsh")
|
||||||
|
|
||||||
|
local nmap = require("opdavies.keymap").nmap
|
||||||
|
|
||||||
|
nmap { "<leader>gm", telescope.extensions.git_worktree.create_git_worktree }
|
||||||
|
nmap { "<leader>gw", telescope.extensions.git_worktree.git_worktrees }
|
||||||
|
|
||||||
|
return telescope_mapper
|
63
lua/opdavies/telescope/setup.lua
Normal file
63
lua/opdavies/telescope/setup.lua
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
local status_ok, telescope = pcall(require, "telescope")
|
||||||
|
if not status_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local previewers = require "telescope.previewers"
|
||||||
|
local Job = require "plenary.job"
|
||||||
|
|
||||||
|
-- Create a new maker that won't preview binary files
|
||||||
|
-- https://github.com/nvim-telescope/telescope.nvim/wiki/Configuration-Recipes#dont-preview-binaries
|
||||||
|
local new_maker = function(filepath, bufnr, opts)
|
||||||
|
filepath = vim.fn.expand(filepath)
|
||||||
|
Job:new({
|
||||||
|
command = "file",
|
||||||
|
args = { "--mime-type", "-b", filepath },
|
||||||
|
on_exit = function(j)
|
||||||
|
local mime_type = vim.split(j:result()[1], "/")[1]
|
||||||
|
if mime_type == "text" then
|
||||||
|
previewers.buffer_previewer_maker(filepath, bufnr, opts)
|
||||||
|
else
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { "BINARY" })
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
}):sync()
|
||||||
|
end
|
||||||
|
|
||||||
|
local action_layout = require "telescope.actions.layout"
|
||||||
|
local actions = require "telescope.actions"
|
||||||
|
|
||||||
|
telescope.setup {
|
||||||
|
defaults = {
|
||||||
|
buffer_previewer_maker = new_maker,
|
||||||
|
mappings = {
|
||||||
|
i = {
|
||||||
|
["<C-h>"] = actions.which_key,
|
||||||
|
["<C-p>"] = action_layout.toggle_preview,
|
||||||
|
},
|
||||||
|
n = {
|
||||||
|
["<C-p>"] = action_layout.toggle_preview,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
no_ignore = true,
|
||||||
|
prompt_prefix = "$ ",
|
||||||
|
},
|
||||||
|
|
||||||
|
extensions = {
|
||||||
|
file_browser = {
|
||||||
|
theme = "ivy",
|
||||||
|
},
|
||||||
|
|
||||||
|
["ui-select"] = {
|
||||||
|
require("telescope.themes").get_dropdown {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
telescope.load_extension "file_browser"
|
||||||
|
telescope.load_extension "fzf"
|
||||||
|
telescope.load_extension "git_worktree"
|
||||||
|
telescope.load_extension "refactoring"
|
||||||
|
telescope.load_extension "ui-select"
|
Reference in a new issue