Browse Source

feat: add treesitter-textobjects

master
Tovi Jaeschke-Rogers 4 months ago
parent
commit
634c378afa
24 changed files with 1023 additions and 968 deletions
  1. +3
    -3
      .config/nvim/lua/plugins/colorizer.lua
  2. +32
    -32
      .config/nvim/lua/plugins/colorscheme.lua
  3. +51
    -51
      .config/nvim/lua/plugins/flash.lua
  4. +34
    -42
      .config/nvim/lua/plugins/formatting.lua
  5. +44
    -44
      .config/nvim/lua/plugins/fugitive.lua
  6. +16
    -16
      .config/nvim/lua/plugins/gitsigns.lua
  7. +41
    -38
      .config/nvim/lua/plugins/harpoon.lua
  8. +2
    -2
      .config/nvim/lua/plugins/init.lua
  9. +11
    -11
      .config/nvim/lua/plugins/laravel.lua
  10. +263
    -263
      .config/nvim/lua/plugins/lspconfig.lua
  11. +36
    -36
      .config/nvim/lua/plugins/lualine.lua
  12. +51
    -51
      .config/nvim/lua/plugins/neotest.lua
  13. +0
    -1
      .config/nvim/lua/plugins/nvim-cmp.lua
  14. +5
    -5
      .config/nvim/lua/plugins/nvim-go.lua
  15. +106
    -57
      .config/nvim/lua/plugins/nvim-treesitter.lua
  16. +86
    -86
      .config/nvim/lua/plugins/oil.lua
  17. +5
    -5
      .config/nvim/lua/plugins/scissors.lua
  18. +177
    -177
      .config/nvim/lua/plugins/telescope.lua
  19. +1
    -1
      .config/nvim/lua/plugins/tmux.lua
  20. +3
    -3
      .config/nvim/lua/plugins/todo-comments.lua
  21. +35
    -35
      .config/nvim/lua/plugins/trouble.lua
  22. +12
    -0
      .config/nvim/lua/plugins/undotree.lua
  23. +0
    -3
      .config/nvim/lua/plugins/vim-blade.lua
  24. +9
    -6
      .config/nvim/lua/plugins/vim-dadbod.lua

+ 3
- 3
.config/nvim/lua/plugins/colorizer.lua View File

@ -1,5 +1,5 @@
return {
"NvChad/nvim-colorizer.lua",
event = { "BufReadPre", "BufNewFile" },
config = true,
"NvChad/nvim-colorizer.lua",
event = { "BufReadPre", "BufNewFile" },
config = true,
}

+ 32
- 32
.config/nvim/lua/plugins/colorscheme.lua View File

@ -4,26 +4,26 @@ return {
enabled = false,
name = "catppuccin",
priority = 1000,
config = function ()
config = function()
require("catppuccin").setup({
flavour = "mocha", -- latte, frappe, macchiato, mocha
background = { -- :h background
background = { -- :h background
light = "latte",
dark = "mocha",
},
transparent_background = false, -- disables setting the background color.
show_end_of_buffer = false, -- shows the '~' characters after the end of buffers
term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`)
show_end_of_buffer = false, -- shows the '~' characters after the end of buffers
term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`)
dim_inactive = {
enabled = false, -- dims the background color of inactive window
enabled = false, -- dims the background color of inactive window
shade = "dark",
percentage = 0.15, -- percentage of the shade to apply to the inactive window
percentage = 0.15, -- percentage of the shade to apply to the inactive window
},
no_italic = false, -- Force no italic
no_bold = false, -- Force no bold
no_underline = false, -- Force no underline
styles = { -- Handles the styles of general hi groups (see `:h highlight-args`):
comments = { "italic" }, -- Change the style of comments
no_italic = false, -- Force no italic
no_bold = false, -- Force no bold
no_underline = false, -- Force no underline
styles = { -- Handles the styles of general hi groups (see `:h highlight-args`):
comments = { "italic" }, -- Change the style of comments
conditionals = { "italic" },
loops = {},
functions = {},
@ -60,8 +60,8 @@ return {
{
"ellisonleao/gruvbox.nvim",
enabled = false,
priority = 1000 ,
config = function ()
priority = 1000,
config = function()
require("gruvbox").setup()
vim.cmd("colorscheme gruvbox")
end,
@ -70,30 +70,30 @@ return {
{
"rebelot/kanagawa.nvim",
enabled = true,
priority = 1000 ,
config = function ()
priority = 1000,
config = function()
-- Default options:
require('kanagawa').setup({
compile = false, -- enable compiling the colorscheme
undercurl = true, -- enable undercurls
compile = false, -- enable compiling the colorscheme
undercurl = true, -- enable undercurls
commentStyle = { italic = true },
functionStyle = {},
keywordStyle = { italic = true},
keywordStyle = { italic = true },
statementStyle = { bold = true },
typeStyle = {},
transparent = false, -- do not set background color
dimInactive = false, -- dim inactive window `:h hl-NormalNC`
terminalColors = true, -- define vim.g.terminal_color_{0,17}
colors = { -- add/modify theme and palette colors
transparent = false, -- do not set background color
dimInactive = false, -- dim inactive window `:h hl-NormalNC`
terminalColors = true, -- define vim.g.terminal_color_{0,17}
colors = { -- add/modify theme and palette colors
palette = {},
theme = { wave = {}, lotus = {}, dragon = {}, all = {} },
},
overrides = function(colors) -- add/modify highlights
return {}
end,
theme = "wave", -- Load "wave" theme when 'background' option is not set
background = { -- map the value of 'background' option to a theme
dark = "wave", -- try "dragon" !
theme = "wave", -- Load "wave" theme when 'background' option is not set
background = { -- map the value of 'background' option to a theme
dark = "wave", -- try "dragon" !
light = "lotus"
},
})
@ -107,7 +107,7 @@ return {
enabled = false,
lazy = false,
priority = 1000,
config = function ()
config = function()
require('tokyonight').setup()
vim.cmd("colorscheme tokyonight")
end
@ -118,9 +118,9 @@ return {
enabled = false,
lazy = false,
priority = 1000,
config = function ()
config = function()
require('ayu').setup({
mirage = false, -- Set to `true` to use `mirage` variant instead of `dark` for dark background.
mirage = false, -- Set to `true` to use `mirage` variant instead of `dark` for dark background.
terminal = true, -- Set to `false` to let terminal manage its own colors.
overrides = {},
})
@ -136,10 +136,10 @@ return {
priority = 1000,
opts = {},
config = function()
require("flow").setup{
transparent = false, -- Set transparent background.
fluo_color = "pink", -- Fluo color: pink, yellow, orange, or green.
mode = "normal", -- Intensity of the palette: normal, bright, desaturate, or dark. Notice that dark is ugly!
require("flow").setup {
transparent = false, -- Set transparent background.
fluo_color = "pink", -- Fluo color: pink, yellow, orange, or green.
mode = "normal", -- Intensity of the palette: normal, bright, desaturate, or dark. Notice that dark is ugly!
aggressive_spell = false, -- Display colors for spell check.
}


+ 51
- 51
.config/nvim/lua/plugins/flash.lua View File

@ -1,53 +1,53 @@
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",
},
},
}

+ 34
- 42
.config/nvim/lua/plugins/formatting.lua View File

@ -1,47 +1,39 @@
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,
}

+ 44
- 44
.config/nvim/lua/plugins/fugitive.lua View File

@ -1,46 +1,46 @@
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,
}

+ 16
- 16
.config/nvim/lua/plugins/gitsigns.lua View File

@ -1,9 +1,9 @@
return {
"lewis6991/gitsigns.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function ()
config = function()
require('gitsigns').setup({
signs = {
signs = {
add = { text = '' },
change = { text = '' },
delete = { text = '_' },
@ -11,17 +11,17 @@ return {
changedelete = { text = '~' },
untracked = { text = '' },
},
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
watch_gitdir = {
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
watch_gitdir = {
follow_files = true
},
auto_attach = true,
attach_to_untracked = false,
current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
auto_attach = true,
attach_to_untracked = false,
current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
virt_text = true,
virt_text_pos = 'eol',
delay = 0,
@ -29,11 +29,11 @@ return {
virt_text_priority = 100,
},
current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000, -- Disable if file is longer than this (in lines)
preview_config = {
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000, -- Disable if file is longer than this (in lines)
preview_config = {
-- Options passed to nvim_open_win
border = 'single',
style = 'minimal',


+ 41
- 38
.config/nvim/lua/plugins/harpoon.lua View File

@ -1,40 +1,43 @@
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,
}

+ 2
- 2
.config/nvim/lua/plugins/init.lua View File

@ -1,4 +1,4 @@
return {
"nvim-lua/plenary.nvim",
"ray-x/guihua.lua",
"nvim-lua/plenary.nvim",
"ray-x/guihua.lua",
}

+ 11
- 11
.config/nvim/lua/plugins/laravel.lua View File

@ -15,7 +15,7 @@ return {
{ "<leader>lm", ":Laravel related<cr>" },
},
event = { "VeryLazy" },
config = function ()
config = function()
local laravel = require("laravel")
laravel.setup({
@ -31,17 +31,17 @@ return {
default = "docker-compose",
definitions = {
{
name = "sail",
condition = {
file_exists = { "vendor/bin/sail", "docker-compose.yml" },
},
commands = {
sail = { "vendor/bin/sail" },
{
commands = { "php", "composer", "npm", "yarn" },
prefix = { "vendor/bin/sail" },
name = "sail",
condition = {
file_exists = { "vendor/bin/sail", "docker-compose.yml" },
},
commands = {
sail = { "vendor/bin/sail" },
{
commands = { "php", "composer", "npm", "yarn" },
prefix = { "vendor/bin/sail" },
},
},
},
},
{
name = "docker-compose",


+ 263
- 263
.config/nvim/lua/plugins/lspconfig.lua View File

@ -1,265 +1,265 @@
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,
}

+ 36
- 36
.config/nvim/lua/plugins/lualine.lua View File

@ -1,40 +1,40 @@
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,
},
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,
}

+ 51
- 51
.config/nvim/lua/plugins/neotest.lua View File

@ -1,54 +1,54 @@
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",
-- 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,
}

+ 0
- 1
.config/nvim/lua/plugins/nvim-cmp.lua View File

@ -31,7 +31,6 @@ return {
"hrsh7th/cmp-nvim-lsp-signature-help",
},
config = function()
-- See `:help cmp`
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")


+ 5
- 5
.config/nvim/lua/plugins/nvim-go.lua View File

@ -1,14 +1,14 @@
return {
"ray-x/go.nvim",
dependencies = { -- optional packages
"ray-x/go.nvim",
dependencies = { -- optional packages
"ray-x/guihua.lua",
"neovim/nvim-lspconfig",
"nvim-treesitter/nvim-treesitter",
},
event = {"CmdlineEnter"},
ft = {"go", 'gomod'},
event = { "CmdlineEnter" },
ft = { "go", 'gomod' },
build = ':lua require("go.install").update_all_sync()',
config = function ()
config = function()
require("go").setup()
local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {})


+ 106
- 57
.config/nvim/lua/plugins/nvim-treesitter.lua View File

@ -1,65 +1,114 @@
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",
},
-- 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" }
},
-- 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,
},
}

+ 86
- 86
.config/nvim/lua/plugins/oil.lua View File

@ -1,90 +1,90 @@
return {
"stevearc/oil.nvim",
opts = {},
"stevearc/oil.nvim",
opts = {},
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,
}

+ 5
- 5
.config/nvim/lua/plugins/scissors.lua View File

@ -1,8 +1,8 @@
return {
"chrisgrieser/nvim-scissors",
"chrisgrieser/nvim-scissors",
event = "VeryLazy",
dependencies = "nvim-telescope/telescope.nvim",
opts = {
snippetDir = "~/.config/nvim/snippets",
}
dependencies = "nvim-telescope/telescope.nvim",
opts = {
snippetDir = "~/.config/nvim/snippets",
}
}

+ 177
- 177
.config/nvim/lua/plugins/telescope.lua View File

@ -1,181 +1,181 @@
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,
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
- 1
.config/nvim/lua/plugins/tmux.lua View File

@ -1,6 +1,6 @@
return {
"aserowy/tmux.nvim",
config = function ()
config = function()
require("tmux").setup({
copy_sync = {
enable = false


+ 3
- 3
.config/nvim/lua/plugins/todo-comments.lua View File

@ -1,14 +1,14 @@
return {
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
config = function ()
config = function()
require('todo-comments').setup()
vim.keymap.set('n', '<leader>tt', function ()
vim.keymap.set('n', '<leader>tt', function()
vim.cmd('TodoTelescope')
end, {})
vim.keymap.set('n', '<leader>tq', function ()
vim.keymap.set('n', '<leader>tq', function()
vim.cmd('TodoQuickFix')
end, {})
end


+ 35
- 35
.config/nvim/lua/plugins/trouble.lua View File

@ -1,37 +1,37 @@
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)",
},
},
}

+ 12
- 0
.config/nvim/lua/plugins/undotree.lua View File

@ -1,5 +1,17 @@
return {
"mbbill/undotree",
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,
}

+ 0
- 3
.config/nvim/lua/plugins/vim-blade.lua View File

@ -1,3 +0,0 @@
return {
'jwalton512/vim-blade'
}

+ 9
- 6
.config/nvim/lua/plugins/vim-dadbod.lua View File

@ -1,8 +1,15 @@
return {
'kristijanhusak/vim-dadbod-ui',
dependencies = {
{ 'tpope/vim-dadbod', lazy = true },
{ 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true },
{
'tpope/vim-dadbod',
lazy = true,
},
{
'kristijanhusak/vim-dadbod-completion',
ft = { 'sql', 'mysql', 'plsql' },
lazy = true,
},
},
cmd = {
'DBUI',
@ -11,10 +18,6 @@ return {
'DBUIFindBuffer',
},
init = function()
-- Your DBUI configuration
vim.g.db_ui_use_nerd_fonts = 1
-- vim.g.dbs = {
-- }
end,
}

Loading…
Cancel
Save