From 634c378afae0c3363583f7d41b9c6d2cefd0a4b7 Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Wed, 28 Aug 2024 10:59:48 +0930 Subject: [PATCH] feat: add treesitter-textobjects --- .config/nvim/lua/plugins/colorizer.lua | 6 +- .config/nvim/lua/plugins/colorscheme.lua | 64 +-- .config/nvim/lua/plugins/flash.lua | 102 ++-- .config/nvim/lua/plugins/formatting.lua | 76 ++- .config/nvim/lua/plugins/fugitive.lua | 88 ++-- .config/nvim/lua/plugins/gitsigns.lua | 32 +- .config/nvim/lua/plugins/harpoon.lua | 79 +-- .config/nvim/lua/plugins/init.lua | 4 +- .config/nvim/lua/plugins/laravel.lua | 22 +- .config/nvim/lua/plugins/lspconfig.lua | 526 +++++++++---------- .config/nvim/lua/plugins/lualine.lua | 72 +-- .config/nvim/lua/plugins/neotest.lua | 102 ++-- .config/nvim/lua/plugins/nvim-cmp.lua | 1 - .config/nvim/lua/plugins/nvim-go.lua | 10 +- .config/nvim/lua/plugins/nvim-treesitter.lua | 163 ++++-- .config/nvim/lua/plugins/oil.lua | 172 +++--- .config/nvim/lua/plugins/scissors.lua | 10 +- .config/nvim/lua/plugins/telescope.lua | 354 ++++++------- .config/nvim/lua/plugins/tmux.lua | 2 +- .config/nvim/lua/plugins/todo-comments.lua | 6 +- .config/nvim/lua/plugins/trouble.lua | 70 +-- .config/nvim/lua/plugins/undotree.lua | 12 + .config/nvim/lua/plugins/vim-blade.lua | 3 - .config/nvim/lua/plugins/vim-dadbod.lua | 15 +- 24 files changed, 1023 insertions(+), 968 deletions(-) delete mode 100644 .config/nvim/lua/plugins/vim-blade.lua diff --git a/.config/nvim/lua/plugins/colorizer.lua b/.config/nvim/lua/plugins/colorizer.lua index f8cfa97..45ec2c1 100644 --- a/.config/nvim/lua/plugins/colorizer.lua +++ b/.config/nvim/lua/plugins/colorizer.lua @@ -1,5 +1,5 @@ return { - "NvChad/nvim-colorizer.lua", - event = { "BufReadPre", "BufNewFile" }, - config = true, + "NvChad/nvim-colorizer.lua", + event = { "BufReadPre", "BufNewFile" }, + config = true, } diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua index 21c9528..41c7a7a 100644 --- a/.config/nvim/lua/plugins/colorscheme.lua +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -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. } diff --git a/.config/nvim/lua/plugins/flash.lua b/.config/nvim/lua/plugins/flash.lua index d8d4f10..b7f9265 100644 --- a/.config/nvim/lua/plugins/flash.lua +++ b/.config/nvim/lua/plugins/flash.lua @@ -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", - }, - { - "", - 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", + }, + { + "", + mode = { "c" }, + function() + require("flash").toggle() + end, + desc = "Toggle Flash Search", + }, + }, } diff --git a/.config/nvim/lua/plugins/formatting.lua b/.config/nvim/lua/plugins/formatting.lua index f12244a..266701f 100644 --- a/.config/nvim/lua/plugins/formatting.lua +++ b/.config/nvim/lua/plugins/formatting.lua @@ -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" }, "F", function() - conform.format({ - lsp_fallback = true, - async = false, - timeout_ms = 500, - }) - end) + vim.keymap.set({ "n", "v" }, "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, } diff --git a/.config/nvim/lua/plugins/fugitive.lua b/.config/nvim/lua/plugins/fugitive.lua index 7e0888b..7ba3eb7 100644 --- a/.config/nvim/lua/plugins/fugitive.lua +++ b/.config/nvim/lua/plugins/fugitive.lua @@ -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", "gp", "Git push", opts) - vim.api.nvim_buf_set_keymap(0, "n", "gP", "Git pull", opts) - vim.api.nvim_buf_set_keymap(0, "n", "gc", "Git commit", 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", "gg", "Git", opts) - - vim.keymap.set("v", "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", "gp", "Git push", opts) + vim.api.nvim_buf_set_keymap(0, "n", "gP", "Git pull", opts) + vim.api.nvim_buf_set_keymap(0, "n", "gc", "Git commit", 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", "gg", "Git", opts) + + vim.keymap.set("v", "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, } diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua index f2970b1..a70c3ba 100644 --- a/.config/nvim/lua/plugins/gitsigns.lua +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -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 = ', - ', - 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', diff --git a/.config/nvim/lua/plugins/harpoon.lua b/.config/nvim/lua/plugins/harpoon.lua index 0e2560d..506df78 100644 --- a/.config/nvim/lua/plugins/harpoon.lua +++ b/.config/nvim/lua/plugins/harpoon.lua @@ -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", "a", function() - harpoon:list():add() - end, { desc = "Mark file with harpoon" }) - - keymap.set("n", "", function() - harpoon.ui:toggle_quick_menu(harpoon:list()) - end, { desc = "Toggle quick menu for harpoon" }) - - keymap.set("n", "1", function() - harpoon:list():select(1) - end, { desc = "Go to first harpoon file" }) - - keymap.set("n", "2", function() - harpoon:list():select(2) - end, { desc = "Go to second harpoon file" }) - - keymap.set("n", "3", function() - harpoon:list():select(3) - end, { desc = "Go to third harpoon file" }) - - keymap.set("n", "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", "a", function() + harpoon:list():add() + end, { desc = "Mark file with harpoon" }) + + keymap.set("n", "", function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end, { desc = "Toggle quick menu for harpoon" }) + + keymap.set("n", "1", function() + harpoon:list():select(1) + end, { desc = "Go to first harpoon file" }) + + keymap.set("n", "2", function() + harpoon:list():select(2) + end, { desc = "Go to second harpoon file" }) + + keymap.set("n", "3", function() + harpoon:list():select(3) + end, { desc = "Go to third harpoon file" }) + + keymap.set("n", "4", function() + harpoon:list():select(4) + end, { desc = "Go to fourth harpoon file" }) + + keymap.set("n", "", function() harpoon:list():prev() end) + keymap.set("n", "", function() harpoon:list():next() end) + end, } diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua index d8d4206..7d33d10 100644 --- a/.config/nvim/lua/plugins/init.lua +++ b/.config/nvim/lua/plugins/init.lua @@ -1,4 +1,4 @@ return { - "nvim-lua/plenary.nvim", - "ray-x/guihua.lua", + "nvim-lua/plenary.nvim", + "ray-x/guihua.lua", } diff --git a/.config/nvim/lua/plugins/laravel.lua b/.config/nvim/lua/plugins/laravel.lua index c8ebe58..72ec6e4 100644 --- a/.config/nvim/lua/plugins/laravel.lua +++ b/.config/nvim/lua/plugins/laravel.lua @@ -15,7 +15,7 @@ return { { "lm", ":Laravel related" }, }, 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", diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index f2a4924..5bbcc1e 100644 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -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", "Telescope lsp_references", 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", "Telescope lsp_definitions", opts) -- show lsp definitions - - opts.desc = "Show LSP implementations" - keymap.set("n", "gi", "Telescope lsp_implementations", opts) -- show lsp implementations - - opts.desc = "Show LSP type definitions" - keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) -- show lsp type definitions - - opts.desc = "See available code actions" - keymap.set({ "n", "v" }, "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", "rn", vim.lsp.buf.rename, opts) -- smart rename - - opts.desc = "Show buffer diagnostics" - keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) -- show diagnostics for file - - opts.desc = "Show line diagnostics" - keymap.set("n", "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", "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", "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", "Telescope lsp_references", 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", "Telescope lsp_definitions", opts) -- show lsp definitions + + opts.desc = "Show LSP implementations" + keymap.set("n", "gi", "Telescope lsp_implementations", opts) -- show lsp implementations + + opts.desc = "Show LSP type definitions" + keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) -- show lsp type definitions + + opts.desc = "See available code actions" + keymap.set({ "n", "v" }, "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", "rn", vim.lsp.buf.rename, opts) -- smart rename + + opts.desc = "Show buffer diagnostics" + keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) -- show diagnostics for file + + opts.desc = "Show line diagnostics" + keymap.set("n", "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", "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", "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, } diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index 39aa80f..9401cf1 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -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, } diff --git a/.config/nvim/lua/plugins/neotest.lua b/.config/nvim/lua/plugins/neotest.lua index cb5dfa2..40babdc 100644 --- a/.config/nvim/lua/plugins/neotest.lua +++ b/.config/nvim/lua/plugins/neotest.lua @@ -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", "tr", function() - neotest.run.run() - end, { desc = "Run neotest on current function" }) - - keymap.set("n", "tR", function() - neotest.run.run_last() - end, { desc = "Run neotest on most recent test" }) - - keymap.set("n", "tS", function() - neotest.run.stop() - end, { desc = "Stop running tests" }) - - keymap.set("n", "ta", function() - neotest.run.attach() - end, { desc = "Attach to the currently running test" }) - - keymap.set("n", "to", function() - neotest.output.open() - end, { desc = "Open the output of the test" }) - - keymap.set("n", "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", "tr", function() + neotest.run.run() + end, { desc = "Run neotest on current function" }) + + keymap.set("n", "tR", function() + neotest.run.run_last() + end, { desc = "Run neotest on most recent test" }) + + keymap.set("n", "tS", function() + neotest.run.stop() + end, { desc = "Stop running tests" }) + + keymap.set("n", "ta", function() + neotest.run.attach() + end, { desc = "Attach to the currently running test" }) + + keymap.set("n", "to", function() + neotest.output.open() + end, { desc = "Open the output of the test" }) + + keymap.set("n", "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, } diff --git a/.config/nvim/lua/plugins/nvim-cmp.lua b/.config/nvim/lua/plugins/nvim-cmp.lua index b3c1406..9434915 100644 --- a/.config/nvim/lua/plugins/nvim-cmp.lua +++ b/.config/nvim/lua/plugins/nvim-cmp.lua @@ -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") diff --git a/.config/nvim/lua/plugins/nvim-go.lua b/.config/nvim/lua/plugins/nvim-go.lua index 59d35d8..84fac74 100644 --- a/.config/nvim/lua/plugins/nvim-go.lua +++ b/.config/nvim/lua/plugins/nvim-go.lua @@ -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", {}) diff --git a/.config/nvim/lua/plugins/nvim-treesitter.lua b/.config/nvim/lua/plugins/nvim-treesitter.lua index 989ad72..9e63a11 100644 --- a/.config/nvim/lua/plugins/nvim-treesitter.lua +++ b/.config/nvim/lua/plugins/nvim-treesitter.lua @@ -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'] = '', -- 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, + }, } diff --git a/.config/nvim/lua/plugins/oil.lua b/.config/nvim/lua/plugins/oil.lua index 98cc627..68e9e9c 100644 --- a/.config/nvim/lua/plugins/oil.lua +++ b/.config/nvim/lua/plugins/oil.lua @@ -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", - [""] = "actions.select", - [""] = "actions.select_vsplit", - [""] = false, - [""] = "actions.select_tab", - [""] = "actions.preview", - [""] = "actions.close", - [""] = 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", + [""] = "actions.select", + [""] = "actions.select_vsplit", + [""] = false, + [""] = "actions.select_tab", + [""] = "actions.preview", + [""] = "actions.close", + [""] = 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, } diff --git a/.config/nvim/lua/plugins/scissors.lua b/.config/nvim/lua/plugins/scissors.lua index 4060a3a..4e4d05f 100644 --- a/.config/nvim/lua/plugins/scissors.lua +++ b/.config/nvim/lua/plugins/scissors.lua @@ -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", + } } diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index 917d16f..593ba02 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -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 = { - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - [""] = actions.cycle_history_next, - [""] = actions.cycle_history_prev, - [""] = actions.smart_send_to_qflist + actions.open_qflist, - }, - }, - }, - extensions = { - undo = { - side_by_side = true, - mappings = { - i = { - [""] = require("telescope-undo.actions").restore, - }, - n = { - [""] = 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", "", function() - builtin.live_grep({ hidden = true }) - end, {}) - - keymap.set("n", "ff", function() - builtin.live_grep({ hidden = true }) - end, {}) - - keymap.set("n", "", project_files, {}) - - keymap.set("n", "p", project_files, {}) - - keymap.set("n", "fr", builtin.resume, {}) - - keymap.set("n", "fb", builtin.buffers, {}) - keymap.set("n", "fo", builtin.oldfiles, {}) - - keymap.set("n", "m", builtin.marks, {}) - - keymap.set("n", "cc", builtin.commands, {}) - keymap.set("n", "ch", builtin.command_history, {}) - - keymap.set("n", "gb", function() - builtin.git_branches({ - attach_mappings = function(_, map) - map("i", "", actions.git_delete_branch) - map("n", "", actions.git_delete_branch) - return true - end, - }) - end, {}) - - keymap.set("n", "gc", builtin.git_commits, {}) - - keymap.set("n", "vh", builtin.help_tags, {}) - - keymap.set("n", "ds", builtin.lsp_document_symbols, {}) - keymap.set("n", "ws", builtin.lsp_workspace_symbols, {}) - keymap.set("n", "dws", builtin.lsp_dynamic_workspace_symbols, {}) - - keymap.set("n", "gf", function() - builtin.grep_string({ - search = vim.fn.expand(""), - }) - end) - - keymap.set("n", "gF", function() - builtin.grep_string({ - search = vim.fn.expand(""), - }) - end) - - keymap.set("n", "gD", function() - builtin.find_files({ - search_file = vim.fn.expand(""), - }) - end) - - vim.keymap.set("n", "u", "Telescope undo") - end, + mappings = { + i = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + [""] = actions.smart_send_to_qflist + actions.open_qflist, + }, + }, + }, + extensions = { + undo = { + side_by_side = true, + mappings = { + i = { + [""] = require("telescope-undo.actions").restore, + }, + n = { + [""] = 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", "", function() + builtin.live_grep({ hidden = true }) + end, {}) + + keymap.set("n", "ff", function() + builtin.live_grep({ hidden = true }) + end, {}) + + keymap.set("n", "", project_files, {}) + + keymap.set("n", "p", project_files, {}) + + keymap.set("n", "fr", builtin.resume, {}) + + keymap.set("n", "fb", builtin.buffers, {}) + keymap.set("n", "fo", builtin.oldfiles, {}) + + keymap.set("n", "m", builtin.marks, {}) + + keymap.set("n", "cc", builtin.commands, {}) + keymap.set("n", "ch", builtin.command_history, {}) + + keymap.set("n", "gb", function() + builtin.git_branches({ + attach_mappings = function(_, map) + map("i", "", actions.git_delete_branch) + map("n", "", actions.git_delete_branch) + return true + end, + }) + end, {}) + + keymap.set("n", "gc", builtin.git_commits, {}) + + keymap.set("n", "vh", builtin.help_tags, {}) + + keymap.set("n", "ds", builtin.lsp_document_symbols, {}) + keymap.set("n", "ws", builtin.lsp_workspace_symbols, {}) + keymap.set("n", "dws", builtin.lsp_dynamic_workspace_symbols, {}) + + keymap.set("n", "gf", function() + builtin.grep_string({ + search = vim.fn.expand(""), + }) + end) + + keymap.set("n", "gF", function() + builtin.grep_string({ + search = vim.fn.expand(""), + }) + end) + + keymap.set("n", "gD", function() + builtin.find_files({ + search_file = vim.fn.expand(""), + }) + end) + + vim.keymap.set("n", "u", "Telescope undo") + end, } diff --git a/.config/nvim/lua/plugins/tmux.lua b/.config/nvim/lua/plugins/tmux.lua index 2bc4e13..002de08 100644 --- a/.config/nvim/lua/plugins/tmux.lua +++ b/.config/nvim/lua/plugins/tmux.lua @@ -1,6 +1,6 @@ return { "aserowy/tmux.nvim", - config = function () + config = function() require("tmux").setup({ copy_sync = { enable = false diff --git a/.config/nvim/lua/plugins/todo-comments.lua b/.config/nvim/lua/plugins/todo-comments.lua index a758f2c..7f51c2b 100644 --- a/.config/nvim/lua/plugins/todo-comments.lua +++ b/.config/nvim/lua/plugins/todo-comments.lua @@ -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', 'tt', function () + vim.keymap.set('n', 'tt', function() vim.cmd('TodoTelescope') end, {}) - vim.keymap.set('n', 'tq', function () + vim.keymap.set('n', 'tq', function() vim.cmd('TodoQuickFix') end, {}) end diff --git a/.config/nvim/lua/plugins/trouble.lua b/.config/nvim/lua/plugins/trouble.lua index da1f027..04ebd87 100644 --- a/.config/nvim/lua/plugins/trouble.lua +++ b/.config/nvim/lua/plugins/trouble.lua @@ -1,37 +1,37 @@ return { - "folke/trouble.nvim", - opts = {}, - cmd = "Trouble", - keys = { - { - "xx", - "Trouble diagnostics toggle", - desc = "Diagnostics (Trouble)", - }, - { - "xX", - "Trouble diagnostics toggle filter.buf=0", - desc = "Buffer Diagnostics (Trouble)", - }, - { - "cs", - "Trouble symbols toggle focus=false", - desc = "Symbols (Trouble)", - }, - { - "cl", - "Trouble lsp toggle focus=false win.position=right", - desc = "LSP Definitions / references / ... (Trouble)", - }, - { - "xL", - "Trouble loclist toggle", - desc = "Location List (Trouble)", - }, - { - "xQ", - "Trouble qflist toggle", - desc = "Quickfix List (Trouble)", - }, - }, + "folke/trouble.nvim", + opts = {}, + cmd = "Trouble", + keys = { + { + "xx", + "Trouble diagnostics toggle", + desc = "Diagnostics (Trouble)", + }, + { + "xX", + "Trouble diagnostics toggle filter.buf=0", + desc = "Buffer Diagnostics (Trouble)", + }, + { + "cs", + "Trouble symbols toggle focus=false", + desc = "Symbols (Trouble)", + }, + { + "cl", + "Trouble lsp toggle focus=false win.position=right", + desc = "LSP Definitions / references / ... (Trouble)", + }, + { + "xL", + "Trouble loclist toggle", + desc = "Location List (Trouble)", + }, + { + "xQ", + "Trouble qflist toggle", + desc = "Quickfix List (Trouble)", + }, + }, } diff --git a/.config/nvim/lua/plugins/undotree.lua b/.config/nvim/lua/plugins/undotree.lua index 45a9f35..3eb909c 100644 --- a/.config/nvim/lua/plugins/undotree.lua +++ b/.config/nvim/lua/plugins/undotree.lua @@ -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, } diff --git a/.config/nvim/lua/plugins/vim-blade.lua b/.config/nvim/lua/plugins/vim-blade.lua deleted file mode 100644 index f1c92a4..0000000 --- a/.config/nvim/lua/plugins/vim-blade.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - 'jwalton512/vim-blade' -} diff --git a/.config/nvim/lua/plugins/vim-dadbod.lua b/.config/nvim/lua/plugins/vim-dadbod.lua index 533c016..ca35ce2 100644 --- a/.config/nvim/lua/plugins/vim-dadbod.lua +++ b/.config/nvim/lua/plugins/vim-dadbod.lua @@ -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, }