@ -1,5 +1,5 @@ | |||||
return { | return { | ||||
"NvChad/nvim-colorizer.lua", | |||||
event = { "BufReadPre", "BufNewFile" }, | |||||
config = true, | |||||
"NvChad/nvim-colorizer.lua", | |||||
event = { "BufReadPre", "BufNewFile" }, | |||||
config = true, | |||||
} | } |
@ -1,53 +1,53 @@ | |||||
return { | return { | ||||
"folke/flash.nvim", | |||||
event = "VeryLazy", | |||||
opts = { | |||||
modes = { | |||||
char = { | |||||
enabled = false, | |||||
}, | |||||
}, | |||||
}, | |||||
keys = { | |||||
{ | |||||
"s", | |||||
mode = { "n", "x", "o" }, | |||||
function() | |||||
require("flash").jump() | |||||
end, | |||||
desc = "Flash", | |||||
}, | |||||
{ | |||||
"S", | |||||
mode = { "n", "x", "o" }, | |||||
function() | |||||
require("flash").treesitter() | |||||
end, | |||||
desc = "Flash Treesitter", | |||||
}, | |||||
{ | |||||
"r", | |||||
mode = "o", | |||||
function() | |||||
require("flash").remote() | |||||
end, | |||||
desc = "Remote Flash", | |||||
}, | |||||
{ | |||||
"R", | |||||
mode = { "o", "x" }, | |||||
function() | |||||
require("flash").treesitter_search() | |||||
end, | |||||
desc = "Treesitter Search", | |||||
}, | |||||
{ | |||||
"<c-s>", | |||||
mode = { "c" }, | |||||
function() | |||||
require("flash").toggle() | |||||
end, | |||||
desc = "Toggle Flash Search", | |||||
}, | |||||
}, | |||||
"folke/flash.nvim", | |||||
event = "VeryLazy", | |||||
opts = { | |||||
modes = { | |||||
char = { | |||||
enabled = false, | |||||
}, | |||||
}, | |||||
}, | |||||
keys = { | |||||
{ | |||||
"s", | |||||
mode = { "n", "x", "o" }, | |||||
function() | |||||
require("flash").jump() | |||||
end, | |||||
desc = "Flash", | |||||
}, | |||||
{ | |||||
"S", | |||||
mode = { "n", "x", "o" }, | |||||
function() | |||||
require("flash").treesitter() | |||||
end, | |||||
desc = "Flash Treesitter", | |||||
}, | |||||
{ | |||||
"r", | |||||
mode = "o", | |||||
function() | |||||
require("flash").remote() | |||||
end, | |||||
desc = "Remote Flash", | |||||
}, | |||||
{ | |||||
"R", | |||||
mode = { "o", "x" }, | |||||
function() | |||||
require("flash").treesitter_search() | |||||
end, | |||||
desc = "Treesitter Search", | |||||
}, | |||||
{ | |||||
"<c-s>", | |||||
mode = { "c" }, | |||||
function() | |||||
require("flash").toggle() | |||||
end, | |||||
desc = "Toggle Flash Search", | |||||
}, | |||||
}, | |||||
} | } |
@ -1,47 +1,39 @@ | |||||
return { | return { | ||||
"stevearc/conform.nvim", | |||||
event = { "BufReadPre", "BufNewFile" }, | |||||
config = function() | |||||
local conform = require("conform") | |||||
"stevearc/conform.nvim", | |||||
event = { "BufReadPre", "BufNewFile" }, | |||||
config = function() | |||||
local conform = require("conform") | |||||
conform.setup({ | |||||
formatters_by_ft = { | |||||
lua = { "stylua" }, | |||||
go = { "goimports", "gofmt" }, | |||||
javascript = { "prettierd" }, | |||||
typescript = { "prettierd" }, | |||||
vue = { "prettierd" }, | |||||
css = { "prettierd" }, | |||||
html = { "prettierd" }, | |||||
markdown = { "prettierd" }, | |||||
json = { "fixjson" }, | |||||
rust = { "rustfmt" }, | |||||
shell = { "shfmt", "shellcheck" }, | |||||
python = { "isort", "black" }, | |||||
php = { "phpcbf" }, | |||||
}, | |||||
-- format_on_save = { | |||||
-- lsp_fallback = true, | |||||
-- async = false, | |||||
-- timeout_ms = 500, | |||||
-- }, | |||||
-- format_after_save = { | |||||
-- lsp_fallback = true, | |||||
-- }, | |||||
log_level = vim.log.levels.WARN, | |||||
notify_on_error = false, | |||||
}) | |||||
conform.setup({ | |||||
formatters_by_ft = { | |||||
lua = { "stylua" }, | |||||
go = { "goimports", "gofmt" }, | |||||
javascript = { "prettierd" }, | |||||
typescript = { "prettierd" }, | |||||
vue = { "prettierd" }, | |||||
css = { "prettierd" }, | |||||
html = { "prettierd" }, | |||||
markdown = { "prettierd" }, | |||||
json = { "fixjson" }, | |||||
rust = { "rustfmt" }, | |||||
shell = { "shfmt", "shellcheck" }, | |||||
python = { "isort", "black" }, | |||||
php = { "phpcbf" }, | |||||
}, | |||||
log_level = vim.log.levels.WARN, | |||||
notify_on_error = false, | |||||
}) | |||||
vim.keymap.set({ "n", "v" }, "<leader>F", function() | |||||
conform.format({ | |||||
lsp_fallback = true, | |||||
async = false, | |||||
timeout_ms = 500, | |||||
}) | |||||
end) | |||||
vim.keymap.set({ "n", "v" }, "<leader>F", function() | |||||
conform.format({ | |||||
lsp_fallback = true, | |||||
async = false, | |||||
timeout_ms = 500, | |||||
}) | |||||
end) | |||||
conform.formatters.phpcbf = { | |||||
prepend_args = { "--standard=~/.config/phpcs.xml" }, | |||||
} | |||||
end, | |||||
conform.formatters.phpcbf = { | |||||
prepend_args = { "--standard=~/.config/phpcs.xml" }, | |||||
} | |||||
end, | |||||
} | } |
@ -1,46 +1,46 @@ | |||||
return { | return { | ||||
"tpope/vim-fugitive", | |||||
dependencies = { | |||||
"shumphrey/fugitive-gitlab.vim", | |||||
}, | |||||
config = function() | |||||
vim.opt.diffopt = vim.opt.diffopt + "vertical" | |||||
vim.opt.display = vim.opt.display + "lastline" | |||||
local fugitive_augroup = vim.api.nvim_create_augroup("fugitive_mappings", { clear = true }) | |||||
local function set_fugitive_mappings() | |||||
local opts = { noremap = true, silent = true } | |||||
vim.api.nvim_buf_set_keymap(0, "n", "<leader>gp", "<cmd>Git push<CR>", opts) | |||||
vim.api.nvim_buf_set_keymap(0, "n", "<leader>gP", "<cmd>Git pull<CR>", opts) | |||||
vim.api.nvim_buf_set_keymap(0, "n", "<leader>gc", "<cmd>Git commit<CR>", opts) | |||||
end | |||||
-- Create an autocmd to trigger the function when entering a Fugitive buffer | |||||
vim.api.nvim_create_autocmd("FileType", { | |||||
group = fugitive_augroup, | |||||
pattern = "fugitive", | |||||
callback = set_fugitive_mappings, | |||||
}) | |||||
local opts = { noremap = true, silent = true } | |||||
vim.keymap.set("n", "<leader>gg", "<cmd>Git<CR>", opts) | |||||
vim.keymap.set("v", "<leader>gl", function() | |||||
local startPos = vim.fn.getpos("'<") | |||||
local endPos = vim.fn.getpos("'>") | |||||
local startLine = startPos[2] | |||||
local endLine = endPos[2] | |||||
if startLine == 0 or endLine == 0 then | |||||
vim.notify(vim.inspect(vim.fn.getpos("'<")) .. " to " .. vim.inspect(vim.fn.getpos("'>"))) | |||||
return | |||||
end | |||||
vim.cmd(string.format("Git log -L %d,%d:%s", startLine, endLine, vim.fn.expand("%:."))) | |||||
end, opts) | |||||
end, | |||||
"tpope/vim-fugitive", | |||||
dependencies = { | |||||
"shumphrey/fugitive-gitlab.vim", | |||||
}, | |||||
config = function() | |||||
vim.opt.diffopt = vim.opt.diffopt + "vertical" | |||||
vim.opt.display = vim.opt.display + "lastline" | |||||
local fugitive_augroup = vim.api.nvim_create_augroup("fugitive_mappings", { clear = true }) | |||||
local function set_fugitive_mappings() | |||||
local opts = { noremap = true, silent = true } | |||||
vim.api.nvim_buf_set_keymap(0, "n", "<leader>gp", "<cmd>Git push<CR>", opts) | |||||
vim.api.nvim_buf_set_keymap(0, "n", "<leader>gP", "<cmd>Git pull<CR>", opts) | |||||
vim.api.nvim_buf_set_keymap(0, "n", "<leader>gc", "<cmd>Git commit<CR>", opts) | |||||
end | |||||
-- Create an autocmd to trigger the function when entering a Fugitive buffer | |||||
vim.api.nvim_create_autocmd("FileType", { | |||||
group = fugitive_augroup, | |||||
pattern = "fugitive", | |||||
callback = set_fugitive_mappings, | |||||
}) | |||||
local opts = { noremap = true, silent = true } | |||||
vim.keymap.set("n", "<leader>gg", "<cmd>Git<CR>", opts) | |||||
vim.keymap.set("v", "<leader>gl", function() | |||||
local startPos = vim.fn.getpos("'<") | |||||
local endPos = vim.fn.getpos("'>") | |||||
local startLine = startPos[2] | |||||
local endLine = endPos[2] | |||||
if startLine == 0 or endLine == 0 then | |||||
vim.notify(vim.inspect(vim.fn.getpos("'<")) .. " to " .. vim.inspect(vim.fn.getpos("'>"))) | |||||
return | |||||
end | |||||
vim.cmd(string.format("Git log -L %d,%d:%s", startLine, endLine, vim.fn.expand("%:."))) | |||||
end, opts) | |||||
end, | |||||
} | } |
@ -1,40 +1,43 @@ | |||||
return { | return { | ||||
"ThePrimeagen/harpoon", | |||||
branch = "harpoon2", | |||||
dependencies = { | |||||
"nvim-lua/plenary.nvim", | |||||
}, | |||||
config = function() | |||||
local harpoon = require("harpoon") | |||||
-- REQUIRED | |||||
harpoon:setup() | |||||
-- REQUIRED | |||||
local keymap = vim.keymap | |||||
keymap.set("n", "<leader>a", function() | |||||
harpoon:list():add() | |||||
end, { desc = "Mark file with harpoon" }) | |||||
keymap.set("n", "<C-e>", function() | |||||
harpoon.ui:toggle_quick_menu(harpoon:list()) | |||||
end, { desc = "Toggle quick menu for harpoon" }) | |||||
keymap.set("n", "<leader>1", function() | |||||
harpoon:list():select(1) | |||||
end, { desc = "Go to first harpoon file" }) | |||||
keymap.set("n", "<leader>2", function() | |||||
harpoon:list():select(2) | |||||
end, { desc = "Go to second harpoon file" }) | |||||
keymap.set("n", "<leader>3", function() | |||||
harpoon:list():select(3) | |||||
end, { desc = "Go to third harpoon file" }) | |||||
keymap.set("n", "<leader>4", function() | |||||
harpoon:list():select(4) | |||||
end, { desc = "Go to fourth harpoon file" }) | |||||
end, | |||||
"ThePrimeagen/harpoon", | |||||
branch = "harpoon2", | |||||
dependencies = { | |||||
"nvim-lua/plenary.nvim", | |||||
}, | |||||
config = function() | |||||
local harpoon = require("harpoon") | |||||
-- REQUIRED | |||||
harpoon:setup() | |||||
-- REQUIRED | |||||
local keymap = vim.keymap | |||||
keymap.set("n", "<leader>a", function() | |||||
harpoon:list():add() | |||||
end, { desc = "Mark file with harpoon" }) | |||||
keymap.set("n", "<C-e>", function() | |||||
harpoon.ui:toggle_quick_menu(harpoon:list()) | |||||
end, { desc = "Toggle quick menu for harpoon" }) | |||||
keymap.set("n", "<leader>1", function() | |||||
harpoon:list():select(1) | |||||
end, { desc = "Go to first harpoon file" }) | |||||
keymap.set("n", "<leader>2", function() | |||||
harpoon:list():select(2) | |||||
end, { desc = "Go to second harpoon file" }) | |||||
keymap.set("n", "<leader>3", function() | |||||
harpoon:list():select(3) | |||||
end, { desc = "Go to third harpoon file" }) | |||||
keymap.set("n", "<leader>4", function() | |||||
harpoon:list():select(4) | |||||
end, { desc = "Go to fourth harpoon file" }) | |||||
keymap.set("n", "<C-S-P>", function() harpoon:list():prev() end) | |||||
keymap.set("n", "<C-S-N>", function() harpoon:list():next() end) | |||||
end, | |||||
} | } |
@ -1,4 +1,4 @@ | |||||
return { | return { | ||||
"nvim-lua/plenary.nvim", | |||||
"ray-x/guihua.lua", | |||||
"nvim-lua/plenary.nvim", | |||||
"ray-x/guihua.lua", | |||||
} | } |
@ -1,265 +1,265 @@ | |||||
return { | return { | ||||
"neovim/nvim-lspconfig", | |||||
event = { "BufReadPre", "BufNewFile" }, | |||||
dependencies = { | |||||
{ "hrsh7th/cmp-nvim-lsp" }, | |||||
{ "antosha417/nvim-lsp-file-operations", config = true }, | |||||
{ "williamboman/mason.nvim", config = true }, | |||||
{ "williamboman/mason-lspconfig.nvim" }, | |||||
{ "WhoIsSethDaniel/mason-tool-installer.nvim" }, | |||||
{ "j-hui/fidget.nvim", opts = {} }, | |||||
{ "folke/neodev.nvim", opts = {} }, | |||||
}, | |||||
config = function() | |||||
-- import lspconfig plugin | |||||
local lspconfig = require("lspconfig") | |||||
local util = require("lspconfig.util") | |||||
local keymap = vim.keymap | |||||
vim.api.nvim_create_autocmd("LspAttach", { | |||||
group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }), | |||||
callback = function(event) | |||||
local opts = { noremap = true, silent = true } | |||||
-- set keybinds | |||||
opts.desc = "Show LSP references" | |||||
keymap.set("n", "gr", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references | |||||
opts.desc = "Go to declaration" | |||||
keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration | |||||
opts.desc = "Show LSP definitions" | |||||
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions | |||||
opts.desc = "Show LSP implementations" | |||||
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations | |||||
opts.desc = "Show LSP type definitions" | |||||
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions | |||||
opts.desc = "See available code actions" | |||||
keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection | |||||
opts.desc = "Smart rename" | |||||
keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename | |||||
opts.desc = "Show buffer diagnostics" | |||||
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file | |||||
opts.desc = "Show line diagnostics" | |||||
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line | |||||
opts.desc = "Go to previous diagnostic" | |||||
keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer | |||||
opts.desc = "Go to next diagnostic" | |||||
keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer | |||||
opts.desc = "Go to previous diagnostic (error only)" | |||||
keymap.set("n", "[e", function() | |||||
vim.diagnostic.goto_prev({ severity = vim.diagnostic.severity.ERROR }) | |||||
end, opts) | |||||
opts.desc = "Go to next diagnostic (error only)" | |||||
keymap.set("n", "]e", function() | |||||
vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR }) | |||||
end, opts) | |||||
opts.desc = "Show documentation for what is under cursor" | |||||
keymap.set("n", "<leader>ld", vim.diagnostic.setqflist, opts) -- show documentation for what is under cursor | |||||
opts.desc = "Show documentation for what is under cursor" | |||||
keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor | |||||
local client = vim.lsp.get_client_by_id(event.data.client_id) | |||||
if client and client.server_capabilities.documentHighlightProvider then | |||||
vim.api.nvim_create_autocmd("LspDetach", { | |||||
group = vim.api.nvim_create_augroup("lsp-detach", { clear = true }), | |||||
callback = function(event2) | |||||
vim.lsp.buf.clear_references() | |||||
end, | |||||
}) | |||||
end | |||||
-- The following autocommand is used to enable inlay hints in your | |||||
-- code, if the language server you are using supports them | |||||
-- | |||||
-- This may be unwanted, since they displace some of your code | |||||
if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then | |||||
opts.desc = "Toggle Inlay Hints" | |||||
keymap.set("n", "<leader>th", function() | |||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({})) | |||||
end, opts) | |||||
end | |||||
end, | |||||
}) | |||||
local capabilities = vim.lsp.protocol.make_client_capabilities() | |||||
capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) | |||||
-- Function to detect the operating system | |||||
local function get_os() | |||||
local handle = io.popen("uname") | |||||
if not handle then | |||||
return error("Failed to detect operating system") | |||||
end | |||||
local result = handle:read("*a") | |||||
handle:close() | |||||
return result:lower():gsub("%s+", "") | |||||
end | |||||
-- Set the base path based on the operating system | |||||
local os = get_os() | |||||
local base_path = "" | |||||
if os == "darwin" then | |||||
base_path = "/opt/homebrew/lib/node_modules" | |||||
elseif os == "linux" then | |||||
base_path = "/usr/local/lib/node_modules" | |||||
end | |||||
local function get_typescript_server_path(root_dir) | |||||
local global_ts = base_path .. "/typescript/lib" | |||||
local found_ts = "" | |||||
local function check_dir(path) | |||||
found_ts = util.path.join(path, "node_modules", "typescript", "lib") | |||||
if util.path.exists(found_ts) then | |||||
return path | |||||
end | |||||
end | |||||
if util.search_ancestors(root_dir, check_dir) then | |||||
return found_ts | |||||
else | |||||
return global_ts | |||||
end | |||||
end | |||||
local servers = { | |||||
tsserver = { | |||||
init_options = { | |||||
plugins = { | |||||
{ | |||||
name = "@vue/typescript-plugin", | |||||
location = base_path .. "/@vue/typescript-plugin", | |||||
languages = { "javascript", "typescript", "vue" }, | |||||
}, | |||||
}, | |||||
}, | |||||
filetypes = { | |||||
"javascript", | |||||
"typescript", | |||||
"vue", | |||||
}, | |||||
}, | |||||
volar = { | |||||
filetypes = { | |||||
"javascript", | |||||
"typescript", | |||||
"vue", | |||||
}, | |||||
on_new_config = function(new_config, new_root_dir) | |||||
new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir) | |||||
end, | |||||
}, | |||||
cssls = {}, | |||||
intelephense = { | |||||
root_dir = function(pattern) | |||||
---@diagnostic disable-next-line: undefined-field | |||||
local cwd = vim.loop.cwd() | |||||
local root = util.root_pattern("composer.json")(pattern) | |||||
-- prefer cwd if root is a descendant | |||||
return util.path.is_descendant(cwd, root) and cwd or root | |||||
end, | |||||
init_options = { | |||||
licenceKey = vim.fn.expand("$HOME/.local/share/nvim/intelephense-licence.txt"), | |||||
}, | |||||
settings = { | |||||
intelephense = { | |||||
format = { | |||||
enable = true, | |||||
sortUseStatements = false, | |||||
}, | |||||
}, | |||||
}, | |||||
}, | |||||
gopls = { | |||||
cmd = { "gopls" }, | |||||
filetypes = { "go", "gomod", "gowork", "gotmpl" }, | |||||
root_dir = util.root_pattern("go.work", "go.mod", ".git"), | |||||
settings = { | |||||
gopls = { | |||||
completeUnimported = true, | |||||
usePlaceholders = true, | |||||
analyses = { | |||||
unusedparams = true, | |||||
}, | |||||
}, | |||||
}, | |||||
}, | |||||
lua_ls = { | |||||
settings = { -- custom settings for lua | |||||
Lua = { | |||||
-- make the language server recognize "vim" global | |||||
diagnostics = { | |||||
globals = { "vim" }, | |||||
}, | |||||
workspace = { | |||||
-- make language server aware of runtime files | |||||
library = { | |||||
[vim.fn.expand("$VIMRUNTIME/lua")] = true, | |||||
[vim.fn.stdpath("config") .. "/lua"] = true, | |||||
}, | |||||
}, | |||||
}, | |||||
}, | |||||
}, | |||||
dartls = { | |||||
cmd = { "dart", "language-server", "--protocol=lsp" }, | |||||
}, | |||||
rust_analyzer = { | |||||
diagnostics = { | |||||
enable = false, | |||||
}, | |||||
}, | |||||
} | |||||
require("mason").setup() | |||||
local ensure_installed = vim.tbl_keys(servers or {}) | |||||
vim.list_extend(ensure_installed, { | |||||
"stylua", | |||||
"prettier", | |||||
"prettierd", | |||||
"eslint", | |||||
"eslint_d", | |||||
"jsonlint", | |||||
"markdownlint", | |||||
"phpcbf", | |||||
"phpcs", | |||||
"golangci-lint", | |||||
"hadolint", | |||||
"gofumpt", | |||||
"goimports", | |||||
}) | |||||
require("mason-tool-installer").setup({ | |||||
ensure_installed = ensure_installed, | |||||
run_on_start = false, | |||||
}) | |||||
require("mason-lspconfig").setup() | |||||
for server_name, server in pairs(servers) do | |||||
server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) | |||||
require("lspconfig")[server_name].setup(server) | |||||
end | |||||
end, | |||||
"neovim/nvim-lspconfig", | |||||
event = { "BufReadPre", "BufNewFile" }, | |||||
dependencies = { | |||||
{ "hrsh7th/cmp-nvim-lsp" }, | |||||
{ "antosha417/nvim-lsp-file-operations", config = true }, | |||||
{ "williamboman/mason.nvim", config = true }, | |||||
{ "williamboman/mason-lspconfig.nvim" }, | |||||
{ "WhoIsSethDaniel/mason-tool-installer.nvim" }, | |||||
{ "j-hui/fidget.nvim", opts = {} }, | |||||
{ "folke/neodev.nvim", opts = {} }, | |||||
}, | |||||
config = function() | |||||
-- import lspconfig plugin | |||||
local lspconfig = require("lspconfig") | |||||
local util = require("lspconfig.util") | |||||
local keymap = vim.keymap | |||||
vim.api.nvim_create_autocmd("LspAttach", { | |||||
group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }), | |||||
callback = function(event) | |||||
local opts = { noremap = true, silent = true } | |||||
-- set keybinds | |||||
opts.desc = "Show LSP references" | |||||
keymap.set("n", "gr", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references | |||||
opts.desc = "Go to declaration" | |||||
keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration | |||||
opts.desc = "Show LSP definitions" | |||||
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions | |||||
opts.desc = "Show LSP implementations" | |||||
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations | |||||
opts.desc = "Show LSP type definitions" | |||||
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions | |||||
opts.desc = "See available code actions" | |||||
keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection | |||||
opts.desc = "Smart rename" | |||||
keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename | |||||
opts.desc = "Show buffer diagnostics" | |||||
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file | |||||
opts.desc = "Show line diagnostics" | |||||
keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line | |||||
opts.desc = "Go to previous diagnostic" | |||||
keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer | |||||
opts.desc = "Go to next diagnostic" | |||||
keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer | |||||
opts.desc = "Go to previous diagnostic (error only)" | |||||
keymap.set("n", "[e", function() | |||||
vim.diagnostic.goto_prev({ severity = vim.diagnostic.severity.ERROR }) | |||||
end, opts) | |||||
opts.desc = "Go to next diagnostic (error only)" | |||||
keymap.set("n", "]e", function() | |||||
vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR }) | |||||
end, opts) | |||||
opts.desc = "Show documentation for what is under cursor" | |||||
keymap.set("n", "<leader>ld", vim.diagnostic.setqflist, opts) -- show documentation for what is under cursor | |||||
opts.desc = "Show documentation for what is under cursor" | |||||
keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor | |||||
local client = vim.lsp.get_client_by_id(event.data.client_id) | |||||
if client and client.server_capabilities.documentHighlightProvider then | |||||
vim.api.nvim_create_autocmd("LspDetach", { | |||||
group = vim.api.nvim_create_augroup("lsp-detach", { clear = true }), | |||||
callback = function(event2) | |||||
vim.lsp.buf.clear_references() | |||||
end, | |||||
}) | |||||
end | |||||
-- The following autocommand is used to enable inlay hints in your | |||||
-- code, if the language server you are using supports them | |||||
-- | |||||
-- This may be unwanted, since they displace some of your code | |||||
if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then | |||||
opts.desc = "Toggle Inlay Hints" | |||||
keymap.set("n", "<leader>th", function() | |||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({})) | |||||
end, opts) | |||||
end | |||||
end, | |||||
}) | |||||
local capabilities = vim.lsp.protocol.make_client_capabilities() | |||||
capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) | |||||
-- Function to detect the operating system | |||||
local function get_os() | |||||
local handle = io.popen("uname") | |||||
if not handle then | |||||
return error("Failed to detect operating system") | |||||
end | |||||
local result = handle:read("*a") | |||||
handle:close() | |||||
return result:lower():gsub("%s+", "") | |||||
end | |||||
-- Set the base path based on the operating system | |||||
local os = get_os() | |||||
local base_path = "" | |||||
if os == "darwin" then | |||||
base_path = "/opt/homebrew/lib/node_modules" | |||||
elseif os == "linux" then | |||||
base_path = "/usr/local/lib/node_modules" | |||||
end | |||||
local function get_typescript_server_path(root_dir) | |||||
local global_ts = base_path .. "/typescript/lib" | |||||
local found_ts = "" | |||||
local function check_dir(path) | |||||
found_ts = util.path.join(path, "node_modules", "typescript", "lib") | |||||
if util.path.exists(found_ts) then | |||||
return path | |||||
end | |||||
end | |||||
if util.search_ancestors(root_dir, check_dir) then | |||||
return found_ts | |||||
else | |||||
return global_ts | |||||
end | |||||
end | |||||
local servers = { | |||||
tsserver = { | |||||
init_options = { | |||||
plugins = { | |||||
{ | |||||
name = "@vue/typescript-plugin", | |||||
location = base_path .. "/@vue/typescript-plugin", | |||||
languages = { "javascript", "typescript", "vue" }, | |||||
}, | |||||
}, | |||||
}, | |||||
filetypes = { | |||||
"javascript", | |||||
"typescript", | |||||
"vue", | |||||
}, | |||||
}, | |||||
volar = { | |||||
filetypes = { | |||||
"javascript", | |||||
"typescript", | |||||
"vue", | |||||
}, | |||||
on_new_config = function(new_config, new_root_dir) | |||||
new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir) | |||||
end, | |||||
}, | |||||
cssls = {}, | |||||
intelephense = { | |||||
root_dir = function(pattern) | |||||
---@diagnostic disable-next-line: undefined-field | |||||
local cwd = vim.loop.cwd() | |||||
local root = util.root_pattern("composer.json")(pattern) | |||||
-- prefer cwd if root is a descendant | |||||
return util.path.is_descendant(cwd, root) and cwd or root | |||||
end, | |||||
init_options = { | |||||
licenceKey = vim.fn.expand("$HOME/.local/share/nvim/intelephense-licence.txt"), | |||||
}, | |||||
settings = { | |||||
intelephense = { | |||||
format = { | |||||
enable = true, | |||||
sortUseStatements = false, | |||||
}, | |||||
}, | |||||
}, | |||||
}, | |||||
gopls = { | |||||
cmd = { "gopls" }, | |||||
filetypes = { "go", "gomod", "gowork", "gotmpl" }, | |||||
root_dir = util.root_pattern("go.work", "go.mod", ".git"), | |||||
settings = { | |||||
gopls = { | |||||
completeUnimported = true, | |||||
usePlaceholders = true, | |||||
analyses = { | |||||
unusedparams = true, | |||||
}, | |||||
}, | |||||
}, | |||||
}, | |||||
lua_ls = { | |||||
settings = { -- custom settings for lua | |||||
Lua = { | |||||
-- make the language server recognize "vim" global | |||||
diagnostics = { | |||||
globals = { "vim" }, | |||||
}, | |||||
workspace = { | |||||
-- make language server aware of runtime files | |||||
library = { | |||||
[vim.fn.expand("$VIMRUNTIME/lua")] = true, | |||||
[vim.fn.stdpath("config") .. "/lua"] = true, | |||||
}, | |||||
}, | |||||
}, | |||||
}, | |||||
}, | |||||
dartls = { | |||||
cmd = { "dart", "language-server", "--protocol=lsp" }, | |||||
}, | |||||
rust_analyzer = { | |||||
diagnostics = { | |||||
enable = false, | |||||
}, | |||||
}, | |||||
} | |||||
require("mason").setup() | |||||
local ensure_installed = vim.tbl_keys(servers or {}) | |||||
vim.list_extend(ensure_installed, { | |||||
"stylua", | |||||
"prettier", | |||||
"prettierd", | |||||
"eslint", | |||||
"eslint_d", | |||||
"jsonlint", | |||||
"markdownlint", | |||||
"phpcbf", | |||||
"phpcs", | |||||
"golangci-lint", | |||||
"hadolint", | |||||
"gofumpt", | |||||
"goimports", | |||||
}) | |||||
require("mason-tool-installer").setup({ | |||||
ensure_installed = ensure_installed, | |||||
run_on_start = false, | |||||
}) | |||||
require("mason-lspconfig").setup() | |||||
for server_name, server in pairs(servers) do | |||||
server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) | |||||
require("lspconfig")[server_name].setup(server) | |||||
end | |||||
end, | |||||
} | } |
@ -1,40 +1,40 @@ | |||||
return { | return { | ||||
"nvim-lualine/lualine.nvim", | |||||
dependencies = { | |||||
"nvim-tree/nvim-web-devicons", | |||||
"letieu/harpoon-lualine", | |||||
}, | |||||
config = function() | |||||
local lualine = require("lualine") | |||||
local lazy_status = require("lazy.status") | |||||
"nvim-lualine/lualine.nvim", | |||||
dependencies = { | |||||
"nvim-tree/nvim-web-devicons", | |||||
"letieu/harpoon-lualine", | |||||
}, | |||||
config = function() | |||||
local lualine = require("lualine") | |||||
local lazy_status = require("lazy.status") | |||||
lualine.setup({ | |||||
options = { | |||||
theme = "kanagawa", | |||||
component_separators = { left = "", right = "" }, | |||||
section_separators = { left = "", right = "" }, | |||||
lualine.setup({ | |||||
options = { | |||||
theme = "kanagawa", | |||||
component_separators = { left = "", right = "" }, | |||||
section_separators = { left = "", right = "" }, | |||||
globalstatus = true, | globalstatus = true, | ||||
}, | |||||
sections = { | |||||
lualine_b = { | |||||
{ "branch" }, | |||||
{ "diff" }, | |||||
{ "diagnostics" }, | |||||
}, | |||||
lualine_c = { | |||||
{ "filename", file_status = true, path = 1 }, | |||||
{ "harpoon2" }, | |||||
}, | |||||
lualine_x = { | |||||
{ | |||||
lazy_status.updates, | |||||
cond = lazy_status.has_updates, | |||||
color = { fg = "#ff9e64" }, | |||||
}, | |||||
{ "fileformat" }, | |||||
{ "filetype" }, | |||||
}, | |||||
}, | |||||
}) | |||||
end, | |||||
}, | |||||
sections = { | |||||
lualine_b = { | |||||
{ "branch" }, | |||||
{ "diff" }, | |||||
{ "diagnostics" }, | |||||
}, | |||||
lualine_c = { | |||||
{ "filename", file_status = true, path = 1 }, | |||||
{ "harpoon2" }, | |||||
}, | |||||
lualine_x = { | |||||
{ | |||||
lazy_status.updates, | |||||
cond = lazy_status.has_updates, | |||||
color = { fg = "#ff9e64" }, | |||||
}, | |||||
{ "fileformat" }, | |||||
{ "filetype" }, | |||||
}, | |||||
}, | |||||
}) | |||||
end, | |||||
} | } |
@ -1,54 +1,54 @@ | |||||
return { | return { | ||||
"nvim-neotest/neotest", | |||||
dependencies = { | |||||
"nvim-lua/plenary.nvim", | |||||
"nvim-treesitter/nvim-treesitter", | |||||
"antoinemadec/FixCursorHold.nvim", | |||||
"nvim-neotest/neotest", | |||||
dependencies = { | |||||
"nvim-lua/plenary.nvim", | |||||
"nvim-treesitter/nvim-treesitter", | |||||
"antoinemadec/FixCursorHold.nvim", | |||||
"nvim-neotest/nvim-nio", | "nvim-neotest/nvim-nio", | ||||
-- Adapters | |||||
"tovijaeschke/neotest-phpunit", | |||||
"nvim-neotest/neotest-go", | |||||
}, | |||||
config = function() | |||||
local neotest = require("neotest") | |||||
local keymap = vim.keymap | |||||
keymap.set("n", "<leader>tr", function() | |||||
neotest.run.run() | |||||
end, { desc = "Run neotest on current function" }) | |||||
keymap.set("n", "<leader>tR", function() | |||||
neotest.run.run_last() | |||||
end, { desc = "Run neotest on most recent test" }) | |||||
keymap.set("n", "<leader>tS", function() | |||||
neotest.run.stop() | |||||
end, { desc = "Stop running tests" }) | |||||
keymap.set("n", "<leader>ta", function() | |||||
neotest.run.attach() | |||||
end, { desc = "Attach to the currently running test" }) | |||||
keymap.set("n", "<leader>to", function() | |||||
neotest.output.open() | |||||
end, { desc = "Open the output of the test" }) | |||||
keymap.set("n", "<leader>ts", function() | |||||
neotest.summary.toggle() | |||||
end, { desc = "Toggle neotest summary pane" }) | |||||
neotest.setup({ | |||||
adapters = { | |||||
require("neotest-phpunit")({ | |||||
root_files = { "phpunit.xml", "composer.json" }, | |||||
-- phpunit_cmd = { "docker", "compose", "exec", "fpm", "./vendor/bin/phpunit" }, | |||||
phpunit_cmd = { "docker", "compose", "exec", "app-fpm", "./vendor/bin/phpunit" }, | |||||
filter_dirs = { "vendor" }, | |||||
mapped_docker_dir = "/var/www", | |||||
append_to_cwd = "/api", | |||||
}), | |||||
}, | |||||
}) | |||||
end, | |||||
-- Adapters | |||||
"tovijaeschke/neotest-phpunit", | |||||
"nvim-neotest/neotest-go", | |||||
}, | |||||
config = function() | |||||
local neotest = require("neotest") | |||||
local keymap = vim.keymap | |||||
keymap.set("n", "<leader>tr", function() | |||||
neotest.run.run() | |||||
end, { desc = "Run neotest on current function" }) | |||||
keymap.set("n", "<leader>tR", function() | |||||
neotest.run.run_last() | |||||
end, { desc = "Run neotest on most recent test" }) | |||||
keymap.set("n", "<leader>tS", function() | |||||
neotest.run.stop() | |||||
end, { desc = "Stop running tests" }) | |||||
keymap.set("n", "<leader>ta", function() | |||||
neotest.run.attach() | |||||
end, { desc = "Attach to the currently running test" }) | |||||
keymap.set("n", "<leader>to", function() | |||||
neotest.output.open() | |||||
end, { desc = "Open the output of the test" }) | |||||
keymap.set("n", "<leader>ts", function() | |||||
neotest.summary.toggle() | |||||
end, { desc = "Toggle neotest summary pane" }) | |||||
neotest.setup({ | |||||
adapters = { | |||||
require("neotest-phpunit")({ | |||||
root_files = { "phpunit.xml", "composer.json" }, | |||||
-- phpunit_cmd = { "docker", "compose", "exec", "fpm", "./vendor/bin/phpunit" }, | |||||
phpunit_cmd = { "docker", "compose", "exec", "app-fpm", "./vendor/bin/phpunit" }, | |||||
filter_dirs = { "vendor" }, | |||||
mapped_docker_dir = "/var/www", | |||||
append_to_cwd = "/api", | |||||
}), | |||||
}, | |||||
}) | |||||
end, | |||||
} | } |
@ -1,65 +1,114 @@ | |||||
return { | return { | ||||
{ | |||||
"nvim-treesitter/nvim-treesitter", | |||||
event = { "BufReadPre", "BufNewFile" }, | |||||
build = ":TSUpdate", | |||||
config = function() | |||||
-- import nvim-treesitter plugin | |||||
local treesitter = require("nvim-treesitter.configs") | |||||
{ | |||||
"nvim-treesitter/nvim-treesitter", | |||||
event = { "BufReadPre", "BufNewFile" }, | |||||
build = ":TSUpdate", | |||||
dependencies = { | |||||
{ "nvim-treesitter/nvim-treesitter-textobjects" }, | |||||
}, | |||||
config = function() | |||||
-- import nvim-treesitter plugin | |||||
local treesitter = require("nvim-treesitter.configs") | |||||
-- configure treesitter | |||||
treesitter.setup({ | |||||
-- ensure these language parsers are installed | |||||
ensure_installed = { | |||||
"json", | |||||
"javascript", | |||||
"typescript", | |||||
"tsx", | |||||
"yaml", | |||||
"html", | |||||
"css", | |||||
"prisma", | |||||
"markdown", | |||||
"markdown_inline", | |||||
"svelte", | |||||
"graphql", | |||||
"bash", | |||||
"lua", | |||||
"vim", | |||||
"dockerfile", | |||||
"gitignore", | |||||
"php", | |||||
-- configure treesitter | |||||
treesitter.setup({ | |||||
-- ensure these language parsers are installed | |||||
ensure_installed = { | |||||
"json", | |||||
"javascript", | |||||
"typescript", | |||||
"tsx", | |||||
"yaml", | |||||
"html", | |||||
"css", | |||||
"prisma", | |||||
"markdown", | |||||
"markdown_inline", | |||||
"svelte", | |||||
"graphql", | |||||
"bash", | |||||
"lua", | |||||
"vim", | |||||
"dockerfile", | |||||
"gitignore", | |||||
"php", | |||||
"latex", | "latex", | ||||
}, | |||||
-- auto install above language parsers | |||||
auto_install = true, | |||||
-- enable syntax highlighting | |||||
highlight = { | |||||
enable = true, | |||||
}, | |||||
ignore_install = {}, | |||||
modules = {}, | |||||
sync_install = true, | |||||
auto_install = true, | |||||
highlight = { | |||||
enable = true, | |||||
disable = { "latex" } | disable = { "latex" } | ||||
}, | |||||
-- enable indentation | |||||
indent = { enable = true }, | |||||
-- enable autotagging | |||||
autotag = { enable = true }, | |||||
}) | |||||
}, | |||||
indent = { enable = true }, | |||||
autotag = { enable = true }, | |||||
textobjects = { | |||||
select = { | |||||
enable = true, | |||||
lookahead = true, | |||||
keymaps = { | |||||
["af"] = "@function.outer", | |||||
["if"] = "@function.inner", | |||||
["ac"] = "@conditional.outer", | |||||
["ic"] = "@conditional.inner", | |||||
["al"] = "@loop.outer", | |||||
["il"] = "@loop.inner", | |||||
}, | |||||
selection_modes = { | |||||
['@parameter.outer'] = 'v', -- charwise | |||||
['@function.outer'] = 'V', -- linewise | |||||
['@class.outer'] = '<c-v>', -- blockwise | |||||
}, | |||||
include_surrounding_whitespace = false, | |||||
}, | |||||
move = { | |||||
enable = true, | |||||
set_jumps = true, | |||||
goto_next_start = { | |||||
["]f"] = "@function.outer", | |||||
["]c"] = "@conditional.outer", | |||||
["]o"] = "@loop.outer", | |||||
}, | |||||
goto_next_end = { | |||||
["]F"] = "@function.outer", | |||||
["]C"] = "@conditional.outer", | |||||
["]O"] = "@loop.outer", | |||||
}, | |||||
goto_previous_start = { | |||||
["[f"] = "@function.outer", | |||||
["[c"] = "@conditional.outer", | |||||
["[o"] = "@loop.outer", | |||||
}, | |||||
goto_previous_end = { | |||||
["[F"] = "@function.outer", | |||||
["[C"] = "@conditional.outer", | |||||
["[O"] = "@loop.outer", | |||||
}, | |||||
}, | |||||
}, | |||||
}) | |||||
local parser_config = require("nvim-treesitter.parsers").get_parser_configs() | |||||
---@class ParserConfig | |||||
---@field install_info table | |||||
---@field filetype string | |||||
local parser_config = require("nvim-treesitter.parsers").get_parser_configs() | |||||
parser_config.blade = { | |||||
install_info = { | |||||
url = "https://github.com/EmranMR/tree-sitter-blade", | |||||
files = { "src/parser.c" }, | |||||
branch = "main", | |||||
}, | |||||
filetype = "blade", | |||||
} | |||||
parser_config.blade = { | |||||
install_info = { | |||||
url = "https://github.com/EmranMR/tree-sitter-blade", | |||||
files = { "src/parser.c" }, | |||||
branch = "main", | |||||
}, | |||||
filetype = "blade", | |||||
} | |||||
vim.filetype.add({ | |||||
pattern = { | |||||
[".*%.blade%.php"] = "blade", | |||||
}, | |||||
}) | |||||
end, | |||||
}, | |||||
vim.filetype.add({ | |||||
pattern = { | |||||
[".*%.blade%.php"] = "blade", | |||||
}, | |||||
}) | |||||
end, | |||||
}, | |||||
} | } |
@ -1,90 +1,90 @@ | |||||
return { | return { | ||||
"stevearc/oil.nvim", | |||||
opts = {}, | |||||
"stevearc/oil.nvim", | |||||
opts = {}, | |||||
commit = '18272aba9d00a3176a5443d50dbb4464acc167bd', | commit = '18272aba9d00a3176a5443d50dbb4464acc167bd', | ||||
-- Optional dependencies | |||||
dependencies = { "nvim-tree/nvim-web-devicons" }, | |||||
config = function() | |||||
require("oil").setup({ | |||||
default_file_explorer = true, | |||||
buf_options = { | |||||
buflisted = false, | |||||
bufhidden = "hide", | |||||
}, | |||||
win_options = { | |||||
wrap = false, | |||||
signcolumn = "no", | |||||
cursorcolumn = false, | |||||
foldcolumn = "0", | |||||
spell = false, | |||||
list = false, | |||||
conceallevel = 3, | |||||
concealcursor = "nvic", | |||||
}, | |||||
delete_to_trash = false, | |||||
skip_confirm_for_simple_edits = false, | |||||
prompt_save_on_select_new_entry = true, | |||||
cleanup_delay_ms = 2000, | |||||
keymaps = { | |||||
["g?"] = "actions.show_help", | |||||
["<CR>"] = "actions.select", | |||||
["<C-s>"] = "actions.select_vsplit", | |||||
["<C-h>"] = false, | |||||
["<C-t>"] = "actions.select_tab", | |||||
["<C-v>"] = "actions.preview", | |||||
["<C-c>"] = "actions.close", | |||||
["<C-l>"] = false, | |||||
["-"] = "actions.parent", | |||||
["_"] = "actions.open_cwd", | |||||
["`"] = "actions.cd", | |||||
["~"] = "actions.tcd", | |||||
["gs"] = "actions.change_sort", | |||||
["gx"] = "actions.open_external", | |||||
["g."] = "actions.toggle_hidden", | |||||
}, | |||||
use_default_keymaps = false, | |||||
view_options = { | |||||
show_hidden = true, | |||||
is_hidden_file = function(name, bufnr) | |||||
return vim.startswith(name, ".") | |||||
end, | |||||
is_always_hidden = function(name, bufnr) | |||||
return false | |||||
end, | |||||
sort = { | |||||
{ "type", "asc" }, | |||||
{ "name", "asc" }, | |||||
}, | |||||
}, | |||||
preview = { | |||||
max_width = 0.9, | |||||
min_width = { 40, 0.4 }, | |||||
width = nil, | |||||
max_height = 0.9, | |||||
min_height = { 5, 0.1 }, | |||||
height = nil, | |||||
border = "rounded", | |||||
win_options = { | |||||
winblend = 0, | |||||
}, | |||||
}, | |||||
progress = { | |||||
max_width = 0.9, | |||||
min_width = { 40, 0.4 }, | |||||
width = nil, | |||||
max_height = { 10, 0.9 }, | |||||
min_height = { 5, 0.1 }, | |||||
height = nil, | |||||
border = "rounded", | |||||
minimized_border = "none", | |||||
win_options = { | |||||
winblend = 0, | |||||
}, | |||||
}, | |||||
}) | |||||
-- Optional dependencies | |||||
dependencies = { "nvim-tree/nvim-web-devicons" }, | |||||
config = function() | |||||
require("oil").setup({ | |||||
default_file_explorer = true, | |||||
buf_options = { | |||||
buflisted = false, | |||||
bufhidden = "hide", | |||||
}, | |||||
win_options = { | |||||
wrap = false, | |||||
signcolumn = "no", | |||||
cursorcolumn = false, | |||||
foldcolumn = "0", | |||||
spell = false, | |||||
list = false, | |||||
conceallevel = 3, | |||||
concealcursor = "nvic", | |||||
}, | |||||
delete_to_trash = false, | |||||
skip_confirm_for_simple_edits = false, | |||||
prompt_save_on_select_new_entry = true, | |||||
cleanup_delay_ms = 2000, | |||||
keymaps = { | |||||
["g?"] = "actions.show_help", | |||||
["<CR>"] = "actions.select", | |||||
["<C-s>"] = "actions.select_vsplit", | |||||
["<C-h>"] = false, | |||||
["<C-t>"] = "actions.select_tab", | |||||
["<C-v>"] = "actions.preview", | |||||
["<C-c>"] = "actions.close", | |||||
["<C-l>"] = false, | |||||
["-"] = "actions.parent", | |||||
["_"] = "actions.open_cwd", | |||||
["`"] = "actions.cd", | |||||
["~"] = "actions.tcd", | |||||
["gs"] = "actions.change_sort", | |||||
["gx"] = "actions.open_external", | |||||
["g."] = "actions.toggle_hidden", | |||||
}, | |||||
use_default_keymaps = false, | |||||
view_options = { | |||||
show_hidden = true, | |||||
is_hidden_file = function(name, _) | |||||
return vim.startswith(name, ".") | |||||
end, | |||||
is_always_hidden = function(_, _) | |||||
return false | |||||
end, | |||||
sort = { | |||||
{ "type", "asc" }, | |||||
{ "name", "asc" }, | |||||
}, | |||||
}, | |||||
preview = { | |||||
max_width = 0.9, | |||||
min_width = { 40, 0.4 }, | |||||
width = nil, | |||||
max_height = 0.9, | |||||
min_height = { 5, 0.1 }, | |||||
height = nil, | |||||
border = "rounded", | |||||
win_options = { | |||||
winblend = 0, | |||||
}, | |||||
}, | |||||
progress = { | |||||
max_width = 0.9, | |||||
min_width = { 40, 0.4 }, | |||||
width = nil, | |||||
max_height = { 10, 0.9 }, | |||||
min_height = { 5, 0.1 }, | |||||
height = nil, | |||||
border = "rounded", | |||||
minimized_border = "none", | |||||
win_options = { | |||||
winblend = 0, | |||||
}, | |||||
}, | |||||
}) | |||||
vim.keymap.set("n", "-", function() | |||||
vim.cmd("Oil") | |||||
end, { desc = "Open parent directory" }) | |||||
end, | |||||
vim.keymap.set("n", "-", function() | |||||
vim.cmd("Oil") | |||||
end, { desc = "Open parent directory" }) | |||||
end, | |||||
} | } |
@ -1,8 +1,8 @@ | |||||
return { | return { | ||||
"chrisgrieser/nvim-scissors", | |||||
"chrisgrieser/nvim-scissors", | |||||
event = "VeryLazy", | event = "VeryLazy", | ||||
dependencies = "nvim-telescope/telescope.nvim", | |||||
opts = { | |||||
snippetDir = "~/.config/nvim/snippets", | |||||
} | |||||
dependencies = "nvim-telescope/telescope.nvim", | |||||
opts = { | |||||
snippetDir = "~/.config/nvim/snippets", | |||||
} | |||||
} | } |
@ -1,181 +1,181 @@ | |||||
return { | return { | ||||
"nvim-telescope/telescope.nvim", | |||||
dependencies = { | |||||
"nvim-lua/plenary.nvim", | |||||
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, | |||||
"nvim-tree/nvim-web-devicons", | |||||
"debugloop/telescope-undo.nvim", | |||||
"nvim-telescope/telescope-ui-select.nvim", | |||||
}, | |||||
config = function() | |||||
local telescope = require("telescope") | |||||
local actions = require("telescope.actions") | |||||
local previewers = require("telescope.previewers") | |||||
local previewers_utils = require("telescope.previewers.utils") | |||||
local sorters = require("telescope.sorters") | |||||
local builtin = require("telescope.builtin") | |||||
local max_size = 100000 | |||||
local truncate_large_files = function(filepath, bufnr, opts) | |||||
opts = opts or {} | |||||
filepath = vim.fn.expand(filepath) | |||||
---@diagnostic disable-next-line: undefined-field | |||||
vim.loop.fs_stat(filepath, function(_, stat) | |||||
if not stat then | |||||
return | |||||
end | |||||
if stat.size > max_size then | |||||
local cmd = { "head", "-c", max_size, filepath } | |||||
previewers_utils.job_maker(cmd, bufnr, opts) | |||||
else | |||||
previewers.buffer_previewer_maker(filepath, bufnr, opts) | |||||
end | |||||
end) | |||||
end | |||||
telescope.setup({ | |||||
defaults = { | |||||
file_sorter = sorters.get_fzy_sorter, | |||||
color_devicons = true, | |||||
buffer_previewer_maker = truncate_large_files, | |||||
initial_mode = "insert", | |||||
selection_strategy = "reset", | |||||
sorting_strategy = "ascending", | |||||
layout_strategy = "horizontal", | |||||
layout_config = { | |||||
horizontal = { | |||||
prompt_position = "top", | |||||
preview_width = 0.55, | |||||
results_width = 0.8, | |||||
}, | |||||
vertical = { | |||||
mirror = false, | |||||
}, | |||||
width = 0.87, | |||||
height = 0.80, | |||||
preview_cutoff = 120, | |||||
}, | |||||
path_display = { "truncate" }, | |||||
winblend = 0, | |||||
border = {}, | |||||
"nvim-telescope/telescope.nvim", | |||||
dependencies = { | |||||
"nvim-lua/plenary.nvim", | |||||
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, | |||||
"nvim-tree/nvim-web-devicons", | |||||
"debugloop/telescope-undo.nvim", | |||||
"nvim-telescope/telescope-ui-select.nvim", | |||||
}, | |||||
config = function() | |||||
local telescope = require("telescope") | |||||
local actions = require("telescope.actions") | |||||
local previewers = require("telescope.previewers") | |||||
local previewers_utils = require("telescope.previewers.utils") | |||||
local sorters = require("telescope.sorters") | |||||
local builtin = require("telescope.builtin") | |||||
local max_size = 100000 | |||||
local truncate_large_files = function(filepath, bufnr, opts) | |||||
opts = opts or {} | |||||
filepath = vim.fn.expand(filepath) | |||||
---@diagnostic disable-next-line: undefined-field | |||||
vim.loop.fs_stat(filepath, function(_, stat) | |||||
if not stat then | |||||
return | |||||
end | |||||
if stat.size > max_size then | |||||
local cmd = { "head", "-c", max_size, filepath } | |||||
previewers_utils.job_maker(cmd, bufnr, opts) | |||||
else | |||||
previewers.buffer_previewer_maker(filepath, bufnr, opts) | |||||
end | |||||
end) | |||||
end | |||||
telescope.setup({ | |||||
defaults = { | |||||
file_sorter = sorters.get_fzy_sorter, | |||||
color_devicons = true, | |||||
buffer_previewer_maker = truncate_large_files, | |||||
initial_mode = "insert", | |||||
selection_strategy = "reset", | |||||
sorting_strategy = "ascending", | |||||
layout_strategy = "horizontal", | |||||
layout_config = { | |||||
horizontal = { | |||||
prompt_position = "top", | |||||
preview_width = 0.55, | |||||
results_width = 0.8, | |||||
}, | |||||
vertical = { | |||||
mirror = false, | |||||
}, | |||||
width = 0.87, | |||||
height = 0.80, | |||||
preview_cutoff = 120, | |||||
}, | |||||
path_display = { "truncate" }, | |||||
winblend = 0, | |||||
border = {}, | |||||
borderchars = nil, | borderchars = nil, | ||||
mappings = { | |||||
i = { | |||||
["<C-n>"] = actions.move_selection_next, | |||||
["<C-p>"] = actions.move_selection_previous, | |||||
["<C-j>"] = actions.cycle_history_next, | |||||
["<C-k>"] = actions.cycle_history_prev, | |||||
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, | |||||
}, | |||||
}, | |||||
}, | |||||
extensions = { | |||||
undo = { | |||||
side_by_side = true, | |||||
mappings = { | |||||
i = { | |||||
["<CR>"] = require("telescope-undo.actions").restore, | |||||
}, | |||||
n = { | |||||
["<CR>"] = require("telescope-undo.actions").restore, | |||||
["y"] = require("telescope-undo.actions").yank_additions, | |||||
["Y"] = require("telescope-undo.actions").yank_deletions, | |||||
["u"] = require("telescope-undo.actions").restore, | |||||
}, | |||||
}, | |||||
}, | |||||
["ui-select"] = { | |||||
require("telescope.themes").get_dropdown({}), | |||||
}, | |||||
}, | |||||
}) | |||||
telescope.load_extension("fzf") | |||||
telescope.load_extension("undo") | |||||
telescope.load_extension("ui-select") | |||||
-- We cache the results of "git rev-parse" | |||||
-- Process creation is expensive in Windows, so this reduces latency | |||||
local is_inside_work_tree = {} | |||||
local project_files = function() | |||||
local cwd = vim.fn.getcwd() | |||||
if is_inside_work_tree[cwd] == nil then | |||||
vim.fn.system("git rev-parse --is-inside-work-tree") | |||||
is_inside_work_tree[cwd] = vim.v.shell_error == 0 | |||||
end | |||||
if is_inside_work_tree[cwd] then | |||||
builtin.git_files({ show_untracked = true, hidden = true }) | |||||
else | |||||
builtin.find_files({}) | |||||
end | |||||
end | |||||
-- set keymaps | |||||
local keymap = vim.keymap | |||||
keymap.set("n", "<C-g>", function() | |||||
builtin.live_grep({ hidden = true }) | |||||
end, {}) | |||||
keymap.set("n", "<leader>ff", function() | |||||
builtin.live_grep({ hidden = true }) | |||||
end, {}) | |||||
keymap.set("n", "<C-p>", project_files, {}) | |||||
keymap.set("n", "<leader>p", project_files, {}) | |||||
keymap.set("n", "<leader>fr", builtin.resume, {}) | |||||
keymap.set("n", "<leader>fb", builtin.buffers, {}) | |||||
keymap.set("n", "<leader>fo", builtin.oldfiles, {}) | |||||
keymap.set("n", "<leader>m", builtin.marks, {}) | |||||
keymap.set("n", "<leader>cc", builtin.commands, {}) | |||||
keymap.set("n", "<leader>ch", builtin.command_history, {}) | |||||
keymap.set("n", "<leader>gb", function() | |||||
builtin.git_branches({ | |||||
attach_mappings = function(_, map) | |||||
map("i", "<c-d>", actions.git_delete_branch) | |||||
map("n", "<c-d>", actions.git_delete_branch) | |||||
return true | |||||
end, | |||||
}) | |||||
end, {}) | |||||
keymap.set("n", "<leader>gc", builtin.git_commits, {}) | |||||
keymap.set("n", "<leader>vh", builtin.help_tags, {}) | |||||
keymap.set("n", "<leader>ds", builtin.lsp_document_symbols, {}) | |||||
keymap.set("n", "<leader>ws", builtin.lsp_workspace_symbols, {}) | |||||
keymap.set("n", "<leader>dws", builtin.lsp_dynamic_workspace_symbols, {}) | |||||
keymap.set("n", "<leader>gf", function() | |||||
builtin.grep_string({ | |||||
search = vim.fn.expand("<cword>"), | |||||
}) | |||||
end) | |||||
keymap.set("n", "<leader>gF", function() | |||||
builtin.grep_string({ | |||||
search = vim.fn.expand("<cWORD>"), | |||||
}) | |||||
end) | |||||
keymap.set("n", "<leader>gD", function() | |||||
builtin.find_files({ | |||||
search_file = vim.fn.expand("<cword>"), | |||||
}) | |||||
end) | |||||
vim.keymap.set("n", "<leader>u", "<cmd>Telescope undo<cr>") | |||||
end, | |||||
mappings = { | |||||
i = { | |||||
["<C-n>"] = actions.move_selection_next, | |||||
["<C-p>"] = actions.move_selection_previous, | |||||
["<C-j>"] = actions.cycle_history_next, | |||||
["<C-k>"] = actions.cycle_history_prev, | |||||
["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, | |||||
}, | |||||
}, | |||||
}, | |||||
extensions = { | |||||
undo = { | |||||
side_by_side = true, | |||||
mappings = { | |||||
i = { | |||||
["<CR>"] = require("telescope-undo.actions").restore, | |||||
}, | |||||
n = { | |||||
["<CR>"] = require("telescope-undo.actions").restore, | |||||
["y"] = require("telescope-undo.actions").yank_additions, | |||||
["Y"] = require("telescope-undo.actions").yank_deletions, | |||||
["u"] = require("telescope-undo.actions").restore, | |||||
}, | |||||
}, | |||||
}, | |||||
["ui-select"] = { | |||||
require("telescope.themes").get_dropdown({}), | |||||
}, | |||||
}, | |||||
}) | |||||
telescope.load_extension("fzf") | |||||
telescope.load_extension("undo") | |||||
telescope.load_extension("ui-select") | |||||
-- We cache the results of "git rev-parse" | |||||
-- Process creation is expensive in Windows, so this reduces latency | |||||
local is_inside_work_tree = {} | |||||
local project_files = function() | |||||
local cwd = vim.fn.getcwd() | |||||
if is_inside_work_tree[cwd] == nil then | |||||
vim.fn.system("git rev-parse --is-inside-work-tree") | |||||
is_inside_work_tree[cwd] = vim.v.shell_error == 0 | |||||
end | |||||
if is_inside_work_tree[cwd] then | |||||
builtin.git_files({ show_untracked = true, hidden = true }) | |||||
else | |||||
builtin.find_files({}) | |||||
end | |||||
end | |||||
-- set keymaps | |||||
local keymap = vim.keymap | |||||
keymap.set("n", "<C-g>", function() | |||||
builtin.live_grep({ hidden = true }) | |||||
end, {}) | |||||
keymap.set("n", "<leader>ff", function() | |||||
builtin.live_grep({ hidden = true }) | |||||
end, {}) | |||||
keymap.set("n", "<C-p>", project_files, {}) | |||||
keymap.set("n", "<leader>p", project_files, {}) | |||||
keymap.set("n", "<leader>fr", builtin.resume, {}) | |||||
keymap.set("n", "<leader>fb", builtin.buffers, {}) | |||||
keymap.set("n", "<leader>fo", builtin.oldfiles, {}) | |||||
keymap.set("n", "<leader>m", builtin.marks, {}) | |||||
keymap.set("n", "<leader>cc", builtin.commands, {}) | |||||
keymap.set("n", "<leader>ch", builtin.command_history, {}) | |||||
keymap.set("n", "<leader>gb", function() | |||||
builtin.git_branches({ | |||||
attach_mappings = function(_, map) | |||||
map("i", "<c-d>", actions.git_delete_branch) | |||||
map("n", "<c-d>", actions.git_delete_branch) | |||||
return true | |||||
end, | |||||
}) | |||||
end, {}) | |||||
keymap.set("n", "<leader>gc", builtin.git_commits, {}) | |||||
keymap.set("n", "<leader>vh", builtin.help_tags, {}) | |||||
keymap.set("n", "<leader>ds", builtin.lsp_document_symbols, {}) | |||||
keymap.set("n", "<leader>ws", builtin.lsp_workspace_symbols, {}) | |||||
keymap.set("n", "<leader>dws", builtin.lsp_dynamic_workspace_symbols, {}) | |||||
keymap.set("n", "<leader>gf", function() | |||||
builtin.grep_string({ | |||||
search = vim.fn.expand("<cword>"), | |||||
}) | |||||
end) | |||||
keymap.set("n", "<leader>gF", function() | |||||
builtin.grep_string({ | |||||
search = vim.fn.expand("<cWORD>"), | |||||
}) | |||||
end) | |||||
keymap.set("n", "<leader>gD", function() | |||||
builtin.find_files({ | |||||
search_file = vim.fn.expand("<cword>"), | |||||
}) | |||||
end) | |||||
vim.keymap.set("n", "<leader>u", "<cmd>Telescope undo<cr>") | |||||
end, | |||||
} | } |
@ -1,14 +1,14 @@ | |||||
return { | return { | ||||
"folke/todo-comments.nvim", | "folke/todo-comments.nvim", | ||||
dependencies = { "nvim-lua/plenary.nvim" }, | dependencies = { "nvim-lua/plenary.nvim" }, | ||||
config = function () | |||||
config = function() | |||||
require('todo-comments').setup() | require('todo-comments').setup() | ||||
vim.keymap.set('n', '<leader>tt', function () | |||||
vim.keymap.set('n', '<leader>tt', function() | |||||
vim.cmd('TodoTelescope') | vim.cmd('TodoTelescope') | ||||
end, {}) | end, {}) | ||||
vim.keymap.set('n', '<leader>tq', function () | |||||
vim.keymap.set('n', '<leader>tq', function() | |||||
vim.cmd('TodoQuickFix') | vim.cmd('TodoQuickFix') | ||||
end, {}) | end, {}) | ||||
end | end | ||||
@ -1,37 +1,37 @@ | |||||
return { | return { | ||||
"folke/trouble.nvim", | |||||
opts = {}, | |||||
cmd = "Trouble", | |||||
keys = { | |||||
{ | |||||
"<leader>xx", | |||||
"<cmd>Trouble diagnostics toggle<cr>", | |||||
desc = "Diagnostics (Trouble)", | |||||
}, | |||||
{ | |||||
"<leader>xX", | |||||
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>", | |||||
desc = "Buffer Diagnostics (Trouble)", | |||||
}, | |||||
{ | |||||
"<leader>cs", | |||||
"<cmd>Trouble symbols toggle focus=false<cr>", | |||||
desc = "Symbols (Trouble)", | |||||
}, | |||||
{ | |||||
"<leader>cl", | |||||
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>", | |||||
desc = "LSP Definitions / references / ... (Trouble)", | |||||
}, | |||||
{ | |||||
"<leader>xL", | |||||
"<cmd>Trouble loclist toggle<cr>", | |||||
desc = "Location List (Trouble)", | |||||
}, | |||||
{ | |||||
"<leader>xQ", | |||||
"<cmd>Trouble qflist toggle<cr>", | |||||
desc = "Quickfix List (Trouble)", | |||||
}, | |||||
}, | |||||
"folke/trouble.nvim", | |||||
opts = {}, | |||||
cmd = "Trouble", | |||||
keys = { | |||||
{ | |||||
"<leader>xx", | |||||
"<cmd>Trouble diagnostics toggle<cr>", | |||||
desc = "Diagnostics (Trouble)", | |||||
}, | |||||
{ | |||||
"<leader>xX", | |||||
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>", | |||||
desc = "Buffer Diagnostics (Trouble)", | |||||
}, | |||||
{ | |||||
"<leader>cs", | |||||
"<cmd>Trouble symbols toggle focus=false<cr>", | |||||
desc = "Symbols (Trouble)", | |||||
}, | |||||
{ | |||||
"<leader>cl", | |||||
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>", | |||||
desc = "LSP Definitions / references / ... (Trouble)", | |||||
}, | |||||
{ | |||||
"<leader>xL", | |||||
"<cmd>Trouble loclist toggle<cr>", | |||||
desc = "Location List (Trouble)", | |||||
}, | |||||
{ | |||||
"<leader>xQ", | |||||
"<cmd>Trouble qflist toggle<cr>", | |||||
desc = "Quickfix List (Trouble)", | |||||
}, | |||||
}, | |||||
} | } |
@ -1,5 +1,17 @@ | |||||
return { | return { | ||||
"mbbill/undotree", | "mbbill/undotree", | ||||
config = function() | config = function() | ||||
if vim.fn.has("persistent_undo") == 0 then | |||||
return | |||||
end | |||||
local target_path = vim.fn.expand("~/.cache/nvim/undodir/") | |||||
if vim.fn.isdirectory(target_path) == 0 then | |||||
vim.fn.mkdir(target_path, "p", 0700) | |||||
end | |||||
vim.opt.undodir = target_path | |||||
vim.opt.undofile = true | |||||
end, | end, | ||||
} | } |
@ -1,3 +0,0 @@ | |||||
return { | |||||
'jwalton512/vim-blade' | |||||
} |