From 64c177f9f4ef0c500ccc5ae1039e5ebb000c3a46 Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Tue, 24 Sep 2024 14:11:17 +0930 Subject: [PATCH] feat: add ThePrimegean/refactoring.nvim --- .config/nvim/lua/core/init.lua | 1 - .config/nvim/lua/core/remaps.lua | 1 + .config/nvim/lua/lazy-plugin-manager.lua | 25 +- .config/nvim/lua/plugins/cloak.lua | 26 +- .config/nvim/lua/plugins/colorizer.lua | 6 +- .config/nvim/lua/plugins/colorscheme.lua | 179 ++------- .config/nvim/lua/plugins/flash.lua | 102 ++--- .config/nvim/lua/plugins/formatting.lua | 68 ++-- .config/nvim/lua/plugins/fugitive.lua | 88 ++--- .config/nvim/lua/plugins/gitsigns.lua | 88 ++--- .config/nvim/lua/plugins/harpoon.lua | 86 +++-- .config/nvim/lua/plugins/init.lua | 4 +- .config/nvim/lua/plugins/laravel.lua | 146 +++---- .config/nvim/lua/plugins/linting.lua | 148 +++---- .config/nvim/lua/plugins/lspconfig.lua | 64 +++- .config/nvim/lua/plugins/nvim-cmp.lua | 169 ++++---- .config/nvim/lua/plugins/nvim-go.lua | 2 +- .config/nvim/lua/plugins/nvim-treesitter.lua | 228 +++++------ .../plugins/nvim-ts-context-commentstring.lua | 6 +- .config/nvim/lua/plugins/oil.lua | 174 ++++----- .config/nvim/lua/plugins/refactoring.lua | 10 + .config/nvim/lua/plugins/scissors.lua | 12 +- .config/nvim/lua/plugins/telescope.lua | 361 +++++++++--------- .config/nvim/lua/plugins/tmux.lua | 34 +- .config/nvim/lua/plugins/todo-comments.lua | 22 +- .config/nvim/lua/plugins/trouble.lua | 76 ++-- .config/nvim/lua/plugins/undotree.lua | 18 +- .config/nvim/lua/plugins/vim-dadbod.lua | 42 +- .zshrc | 2 +- 29 files changed, 1065 insertions(+), 1123 deletions(-) create mode 100644 .config/nvim/lua/plugins/refactoring.lua diff --git a/.config/nvim/lua/core/init.lua b/.config/nvim/lua/core/init.lua index e82d04d..83da743 100644 --- a/.config/nvim/lua/core/init.lua +++ b/.config/nvim/lua/core/init.lua @@ -2,4 +2,3 @@ require('core.options') require('core.remaps') require('core.autocmd') require('core.commands') - diff --git a/.config/nvim/lua/core/remaps.lua b/.config/nvim/lua/core/remaps.lua index 850cb77..e6241c5 100644 --- a/.config/nvim/lua/core/remaps.lua +++ b/.config/nvim/lua/core/remaps.lua @@ -1,3 +1,4 @@ +vim.keymap.set("i", "jk", "", {}) -- Don't copy "c" changes to primary register vim.keymap.set("n", "c", '"_c', { desc = "Prevent copying to primary register" }) diff --git a/.config/nvim/lua/lazy-plugin-manager.lua b/.config/nvim/lua/lazy-plugin-manager.lua index aa4ebcf..d0c2162 100644 --- a/.config/nvim/lua/lazy-plugin-manager.lua +++ b/.config/nvim/lua/lazy-plugin-manager.lua @@ -5,22 +5,21 @@ if not vim.loop.fs_stat(lazypath) then "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release + "--branch=stable", lazypath, }) end vim.opt.rtp:prepend(lazypath) -require("lazy").setup( - { - { import = "plugins" }, - }, - { - checker = { - enabled = true, - notify = false, - }, - change_detection = { - notify = false, - }, +require("lazy").setup({ + { import = "plugins" }, +}, { + checker = { + enabled = true, + notify = false, + }, + change_detection = { + notify = false, + }, + colorscheme = "kanagawa", }) diff --git a/.config/nvim/lua/plugins/cloak.lua b/.config/nvim/lua/plugins/cloak.lua index 1bc2118..c386255 100644 --- a/.config/nvim/lua/plugins/cloak.lua +++ b/.config/nvim/lua/plugins/cloak.lua @@ -1,15 +1,15 @@ return { - "laytan/cloak.nvim", - config = function() - require("cloak").setup({ - enabled = true, - patterns = { - { - file_pattern = ".env*", - cloak_pattern = "=.+", - replace = "*", - }, - } - }) - end, + "laytan/cloak.nvim", + config = function() + require("cloak").setup({ + enabled = true, + patterns = { + { + file_pattern = ".env*", + cloak_pattern = "=.+", + replace = "*", + }, + }, + }) + end, } diff --git a/.config/nvim/lua/plugins/colorizer.lua b/.config/nvim/lua/plugins/colorizer.lua index 45ec2c1..f8cfa97 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 41c7a7a..ff01b0e 100644 --- a/.config/nvim/lua/plugins/colorscheme.lua +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -1,149 +1,34 @@ return { - { - "catppuccin/nvim", - enabled = false, - name = "catppuccin", - priority = 1000, - config = function() - require("catppuccin").setup({ - flavour = "mocha", -- latte, frappe, macchiato, mocha - 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`) - dim_inactive = { - enabled = false, -- dims the background color of inactive window - shade = "dark", - 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 - conditionals = { "italic" }, - loops = {}, - functions = {}, - keywords = {}, - strings = {}, - variables = {}, - numbers = {}, - booleans = {}, - properties = {}, - types = {}, - operators = {}, - -- miscs = {}, -- Uncomment to turn off hard-coded styles - }, - color_overrides = {}, - custom_highlights = {}, - default_integrations = true, - integrations = { - cmp = true, - gitsigns = true, - nvimtree = true, - treesitter = true, - notify = false, - mini = { - enabled = true, - indentscope_color = "", - }, - }, - }) - - vim.cmd("colorscheme catppuccin") - end - }, - - { - "ellisonleao/gruvbox.nvim", - enabled = false, - priority = 1000, - config = function() - require("gruvbox").setup() - vim.cmd("colorscheme gruvbox") - end, - }, - - { - "rebelot/kanagawa.nvim", - enabled = true, - priority = 1000, - config = function() - -- Default options: - require('kanagawa').setup({ - compile = false, -- enable compiling the colorscheme - undercurl = true, -- enable undercurls - commentStyle = { italic = true }, - functionStyle = {}, - 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 - 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" ! - light = "lotus" - }, - }) - - -- setup must be called before loading - vim.cmd("colorscheme kanagawa") - end - }, - { - "folke/tokyonight.nvim", - enabled = false, - lazy = false, - priority = 1000, - config = function() - require('tokyonight').setup() - vim.cmd("colorscheme tokyonight") - end - }, - - { - "Shatur/neovim-ayu", - enabled = false, - lazy = false, - priority = 1000, - config = function() - require('ayu').setup({ - 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 = {}, - }) - vim.cmd("colorscheme ayu-dark") - end - - }, - - { - "0xstepit/flow.nvim", - enabled = false, - lazy = false, - 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! - aggressive_spell = false, -- Display colors for spell check. - } - - vim.cmd("colorscheme flow") - end, - } + "rebelot/kanagawa.nvim", + priority = 1000, + config = function() + -- Default options: + require("kanagawa").setup({ + compile = false, -- enable compiling the colorscheme + undercurl = true, -- enable undercurls + commentStyle = { italic = true }, + functionStyle = {}, + 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 + 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" ! + light = "lotus", + }, + }) + + -- setup must be called before loading + vim.cmd("colorscheme kanagawa") + end, } diff --git a/.config/nvim/lua/plugins/flash.lua b/.config/nvim/lua/plugins/flash.lua index b7f9265..d8d4f10 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 266701f..314af24 100644 --- a/.config/nvim/lua/plugins/formatting.lua +++ b/.config/nvim/lua/plugins/formatting.lua @@ -1,39 +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" }, - }, - 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 7ba3eb7..7e0888b 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 a70c3ba..3cebbd9 100644 --- a/.config/nvim/lua/plugins/gitsigns.lua +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -1,46 +1,46 @@ return { - "lewis6991/gitsigns.nvim", - event = { "BufReadPre", "BufNewFile" }, - config = function() - require('gitsigns').setup({ - signs = { - add = { text = '┃' }, - change = { text = '┃' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - 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 = { - 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 = { - virt_text = true, - virt_text_pos = 'eol', - delay = 0, - ignore_whitespace = false, - 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 = { - -- Options passed to nvim_open_win - border = 'single', - style = 'minimal', - relative = 'cursor', - row = 0, - col = 1 - }, - }) - end + "lewis6991/gitsigns.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() + require("gitsigns").setup({ + signs = { + add = { text = "┃" }, + change = { text = "┃" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "┆" }, + }, + signcolumn = true, + numhl = false, + linehl = false, + word_diff = false, + 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 = { + virt_text = true, + virt_text_pos = "eol", + delay = 0, + ignore_whitespace = false, + 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 = { + -- Options passed to nvim_open_win + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, + }) + end, } diff --git a/.config/nvim/lua/plugins/harpoon.lua b/.config/nvim/lua/plugins/harpoon.lua index 506df78..cdac934 100644 --- a/.config/nvim/lua/plugins/harpoon.lua +++ b/.config/nvim/lua/plugins/harpoon.lua @@ -1,43 +1,47 @@ 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" }) - - keymap.set("n", "", function() harpoon:list():prev() end) - keymap.set("n", "", function() harpoon:list():next() end) - 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 7d33d10..d8d4206 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 72ec6e4..b9abf34 100644 --- a/.config/nvim/lua/plugins/laravel.lua +++ b/.config/nvim/lua/plugins/laravel.lua @@ -1,76 +1,76 @@ return { - "tovijaeschke/laravel.nvim", - -- enabled = false, - branch = "feature/discovery-check-improvements", - dependencies = { - "nvim-telescope/telescope.nvim", - "tpope/vim-dotenv", - "MunifTanjim/nui.nvim", - -- "nvimtools/none-ls.nvim", - }, - cmd = { "Sail", "Artisan", "Composer", "Npm", "Yarn", "Laravel" }, - keys = { - { "la", ":Laravel artisan" }, - { "lr", ":Laravel routes" }, - { "lm", ":Laravel related" }, - }, - event = { "VeryLazy" }, - config = function() - local laravel = require("laravel") + "tovijaeschke/laravel.nvim", + enabled = false, + branch = "feature/discovery-check-improvements", + dependencies = { + "nvim-telescope/telescope.nvim", + "tpope/vim-dotenv", + "MunifTanjim/nui.nvim", + -- "nvimtools/none-ls.nvim", + }, + cmd = { "Sail", "Artisan", "Composer", "Npm", "Yarn", "Laravel" }, + keys = { + { "la", ":Laravel artisan" }, + { "lr", ":Laravel routes" }, + { "lm", ":Laravel related" }, + }, + event = { "VeryLazy" }, + config = function() + local laravel = require("laravel") - laravel.setup({ - lsp_server = "intelephense", - features = { - null_ls = { - enable = false, - }, - }, - environments = { - env_variable = "NVIM_LARAVEL_ENV", - auto_dicover = false, - 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 = "docker-compose", - condition = { - file_exists = { "docker-compose.yml" }, - executable = { "docker" }, - }, - commands = { - compose = { "docker", "compose" }, - { - commands = { "php", "composer", "npm" }, - docker = { - container = { - env = "APP_SERVICE", - default = "fpm", - }, - exec = { "docker", "compose", "exec", "-it" }, - }, - }, - }, - }, - { - name = "local", - condition = { - executable = { "php" }, - }, - }, - } - } - }) - end, + laravel.setup({ + lsp_server = "intelephense", + features = { + null_ls = { + enable = false, + }, + }, + environments = { + env_variable = "NVIM_LARAVEL_ENV", + auto_dicover = false, + 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 = "docker-compose", + condition = { + file_exists = { "docker-compose.yml" }, + executable = { "docker" }, + }, + commands = { + compose = { "docker", "compose" }, + { + commands = { "php", "composer", "npm" }, + docker = { + container = { + env = "APP_SERVICE", + default = "fpm", + }, + exec = { "docker", "compose", "exec", "-it" }, + }, + }, + }, + }, + { + name = "local", + condition = { + executable = { "php" }, + }, + }, + }, + }, + }) + end, } diff --git a/.config/nvim/lua/plugins/linting.lua b/.config/nvim/lua/plugins/linting.lua index d92b296..d63f1fa 100644 --- a/.config/nvim/lua/plugins/linting.lua +++ b/.config/nvim/lua/plugins/linting.lua @@ -1,86 +1,86 @@ return { - "mfussenegger/nvim-lint", - event = { "BufReadPre", "BufNewFile" }, - config = function() - local lint = require("lint") + "mfussenegger/nvim-lint", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local lint = require("lint") - local severities = { - ERROR = vim.diagnostic.severity.ERROR, - WARNING = vim.diagnostic.severity.WARN, - } + local severities = { + ERROR = vim.diagnostic.severity.ERROR, + WARNING = vim.diagnostic.severity.WARN, + } - lint.linters.phpcs = { - name = 'phpcs', - cmd = 'phpcs', - stdin = true, - args = { - '-q', - '--report=json', - '--standard=~/.config/phpcs.xml', - '-', -- need `-` at the end for stdin support - }, - ignore_exitcode = true, - parser = function(output, _) - if vim.trim(output) == '' or output == nil then - return {} - end + lint.linters.phpcs = { + name = "phpcs", + cmd = "phpcs", + stdin = true, + args = { + "-q", + "--report=json", + "--standard=~/.config/phpcs.xml", + "-", -- need `-` at the end for stdin support + }, + ignore_exitcode = true, + parser = function(output, _) + if vim.trim(output) == "" or output == nil then + return {} + end - if not vim.startswith(output, '{') then - vim.notify(output) - return {} - end + if not vim.startswith(output, "{") then + vim.notify(output) + return {} + end - local decoded = vim.json.decode(output) - local diagnostics = {} - local messages = decoded['files']['STDIN']['messages'] + local decoded = vim.json.decode(output) + local diagnostics = {} + local messages = decoded["files"]["STDIN"]["messages"] - for _, msg in ipairs(messages or {}) do - table.insert(diagnostics, { - lnum = msg.line - 1, - end_lnum = msg.line - 1, - col = msg.column - 1, - end_col = msg.column - 1, - message = msg.message, - code = msg.source, - source = 'phpcs', - severity = assert(severities[msg.type], 'missing mapping for severity ' .. msg.type), - }) - end + for _, msg in ipairs(messages or {}) do + table.insert(diagnostics, { + lnum = msg.line - 1, + end_lnum = msg.line - 1, + col = msg.column - 1, + end_col = msg.column - 1, + message = msg.message, + code = msg.source, + source = "phpcs", + severity = assert(severities[msg.type], "missing mapping for severity " .. msg.type), + }) + end - return diagnostics - end - } + return diagnostics + end, + } - lint.linters_by_ft = { - javascript = { "eslint" }, - typescript = { "eslint" }, - vue = { "eslint" }, - json = { "jsonlint" }, - markdown = { "markdownlint" }, - php = { "phpcs" }, - golang = { "gospell", "golangci-lint" }, - python = { "pylint" }, - dockerfile = { "hadolint" }, - blade = { "phpcs" }, - } + lint.linters_by_ft = { + javascript = { "eslint" }, + typescript = { "eslint" }, + vue = { "eslint" }, + json = { "jsonlint" }, + markdown = { "markdownlint" }, + php = { "phpcs" }, + golang = { "gospell", "golangci-lint" }, + python = { "pylint" }, + dockerfile = { "hadolint" }, + blade = { "phpcs" }, + } - local lint_augroup = vim.api.nvim_create_augroup("lint", { - clear = true, - }) + local lint_augroup = vim.api.nvim_create_augroup("lint", { + clear = true, + }) - vim.api.nvim_create_autocmd({ - "BufEnter", - "BufWritePost", - "InsertLeave", - }, { - group = lint_augroup, - callback = function() - lint.try_lint() - end, - }) + vim.api.nvim_create_autocmd({ + "BufEnter", + "BufWritePost", + "InsertLeave", + }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) - vim.keymap.set("n", "ll", function() - lint.try_lint() - end) - end, + vim.keymap.set("n", "ll", function() + lint.try_lint() + end) + end, } diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index 5bbcc1e..7cd1f8f 100644 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -11,7 +11,6 @@ return { { "folke/neodev.nvim", opts = {} }, }, config = function() - -- import lspconfig plugin local lspconfig = require("lspconfig") local util = require("lspconfig.util") @@ -21,39 +20,38 @@ return { 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 + keymap.set("n", "gr", "Telescope lsp_references", opts) opts.desc = "Go to declaration" - keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration + keymap.set("n", "gD", vim.lsp.buf.declaration, opts) opts.desc = "Show LSP definitions" - keymap.set("n", "gd", "Telescope lsp_definitions", opts) -- show lsp definitions + keymap.set("n", "gd", "Telescope lsp_definitions", opts) opts.desc = "Show LSP implementations" - keymap.set("n", "gi", "Telescope lsp_implementations", opts) -- show lsp implementations + keymap.set("n", "gi", "Telescope lsp_implementations", opts) opts.desc = "Show LSP type definitions" - keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) -- show lsp type definitions + keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) 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 + keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) opts.desc = "Smart rename" - keymap.set("n", "rn", vim.lsp.buf.rename, opts) -- smart rename + keymap.set("n", "rn", vim.lsp.buf.rename, opts) opts.desc = "Show buffer diagnostics" - keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) -- show diagnostics for file + keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) opts.desc = "Show line diagnostics" - keymap.set("n", "d", vim.diagnostic.open_float, opts) -- show diagnostics for line + keymap.set("n", "d", vim.diagnostic.open_float, opts) opts.desc = "Go to previous diagnostic" - keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer + keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) opts.desc = "Go to next diagnostic" - keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer + keymap.set("n", "]d", vim.diagnostic.goto_next, opts) opts.desc = "Go to previous diagnostic (error only)" keymap.set("n", "[e", function() @@ -66,10 +64,10 @@ return { 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 + keymap.set("n", "ld", vim.diagnostic.setqflist, opts) 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 + keymap.set("n", "K", vim.lsp.buf.hover, opts) local client = vim.lsp.get_client_by_id(event.data.client_id) if client and client.server_capabilities.documentHighlightProvider then @@ -134,8 +132,28 @@ return { end end + local path = util.path + + local function get_python_path(workspace) + -- Use activated virtualenv. + if vim.env.VIRTUAL_ENV then + return path.join(vim.env.VIRTUAL_ENV, 'bin', 'python') + end + + -- Find and use virtualenv in workspace directory. + for _, pattern in ipairs({'*', '.*'}) do + local match = vim.fn.glob(path.join(workspace, pattern, 'pyvenv.cfg')) + if match ~= '' then + return path.join(path.dirname(match), 'bin', 'python') + end + end + + -- Fallback to system Python. + return exepath('python3') or exepath('python') or 'python' + end + local servers = { - tsserver = { + ts_ls = { init_options = { plugins = { { @@ -229,6 +247,20 @@ return { enable = false, }, }, + + pyright = { + before_init = function(_, config) + config.settings.python.pythonpath = get_python_path(config.root_dir) + end + }, + + yamlls = { + settings = { + yaml = { + keyOrdering = false, + }, + }, + }, } require("mason").setup() diff --git a/.config/nvim/lua/plugins/nvim-cmp.lua b/.config/nvim/lua/plugins/nvim-cmp.lua index 9434915..68cc64c 100644 --- a/.config/nvim/lua/plugins/nvim-cmp.lua +++ b/.config/nvim/lua/plugins/nvim-cmp.lua @@ -1,90 +1,89 @@ return { - "hrsh7th/nvim-cmp", - event = "InsertEnter", - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - { - "L3MON4D3/LuaSnip", - build = (function() - if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then - return - end - return "make install_jsregexp" - end)(), - dependencies = { - { - "rafamadriz/friendly-snippets", - config = function() - require("luasnip.loaders.from_vscode").lazy_load() - end, - }, - }, - }, - "saadparwaiz1/cmp_luasnip", + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + { + "L3MON4D3/LuaSnip", + build = (function() + if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then + return + end + return "make install_jsregexp" + end)(), + dependencies = { + { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, + }, + }, + "saadparwaiz1/cmp_luasnip", - "onsails/lspkind.nvim", - "kristijanhusak/vim-dadbod-completion", + "onsails/lspkind.nvim", + "kristijanhusak/vim-dadbod-completion", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-nvim-lsp-signature-help", - }, - config = function() - local cmp = require("cmp") - local luasnip = require("luasnip") - local lspkind = require("lspkind") - luasnip.config.setup({}) + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-nvim-lsp-signature-help", + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + local lspkind = require("lspkind") + luasnip.config.setup({}) - cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { - completeopt = "menu,menuone,noinsert", - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping.complete({}), - [""] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { "i", "s" }), - [""] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { "i", "s" }), - }), - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "path" }, - { name = "vim-dadbod-completion" }, - }, - formatting = { - expandable_indicator = true, - fields = { "abbr", "kind", "menu" }, - format = lspkind.cmp_format({ - mode = "symbol_text", - menu = { - nvim_lua = "[API]", - nvim_lsp = "[LSP]", - luasnip = "[SNIP]", - vim_dadbod_completion = "[DBUI]", - path = "[PATH]", - buffer = "[BUFF]", - }, - }), - }, - }) - end, + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { + completeopt = "menu,menuone,noinsert", + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete({}), + [""] = cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end, { "i", "s" }), + [""] = cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { "i", "s" }), + }), + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + { name = "vim-dadbod-completion" }, + }, + formatting = { + expandable_indicator = true, + fields = { "abbr", "kind", "menu" }, + format = lspkind.cmp_format({ + mode = "symbol_text", + menu = { + nvim_lua = "[API]", + nvim_lsp = "[LSP]", + luasnip = "[SNIP]", + vim_dadbod_completion = "[DBUI]", + path = "[PATH]", + buffer = "[BUFF]", + }, + }), + }, + }) + end, } diff --git a/.config/nvim/lua/plugins/nvim-go.lua b/.config/nvim/lua/plugins/nvim-go.lua index 84fac74..7d8ec4f 100644 --- a/.config/nvim/lua/plugins/nvim-go.lua +++ b/.config/nvim/lua/plugins/nvim-go.lua @@ -1,6 +1,6 @@ return { "ray-x/go.nvim", - dependencies = { -- optional packages + dependencies = { "ray-x/guihua.lua", "neovim/nvim-lspconfig", "nvim-treesitter/nvim-treesitter", diff --git a/.config/nvim/lua/plugins/nvim-treesitter.lua b/.config/nvim/lua/plugins/nvim-treesitter.lua index 43f77ba..709a3c2 100644 --- a/.config/nvim/lua/plugins/nvim-treesitter.lua +++ b/.config/nvim/lua/plugins/nvim-treesitter.lua @@ -1,120 +1,120 @@ return { - { - "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") + { + "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", - "latex", - }, - ignore_install = {}, - modules = {}, - sync_install = true, - auto_install = true, - highlight = { - enable = true, - disable = { "latex" } - }, - 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", - }, - goto_next = { - ["]b"] = "@block.outer", - }, - goto_previous = { - ["[b"] = "@block.outer", - } - }, - }, - }) + -- 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", + }, + ignore_install = {}, + modules = {}, + sync_install = true, + auto_install = true, + highlight = { + enable = true, + disable = { "latex" }, + }, + 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", + }, + goto_next = { + ["]b"] = "@block.outer", + }, + goto_previous = { + ["[b"] = "@block.outer", + }, + }, + }, + }) - ---@class ParserConfig - ---@field install_info table - ---@field filetype string - 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/nvim-ts-context-commentstring.lua b/.config/nvim/lua/plugins/nvim-ts-context-commentstring.lua index 038cec2..2c3a932 100644 --- a/.config/nvim/lua/plugins/nvim-ts-context-commentstring.lua +++ b/.config/nvim/lua/plugins/nvim-ts-context-commentstring.lua @@ -1,5 +1,5 @@ return { - 'JoosepAlviste/nvim-ts-context-commentstring', - event = { 'BufRead', 'BufNewFile' }, - config = true, + "JoosepAlviste/nvim-ts-context-commentstring", + event = { "BufRead", "BufNewFile" }, + config = true, } diff --git a/.config/nvim/lua/plugins/oil.lua b/.config/nvim/lua/plugins/oil.lua index 68e9e9c..9e391dc 100644 --- a/.config/nvim/lua/plugins/oil.lua +++ b/.config/nvim/lua/plugins/oil.lua @@ -1,90 +1,90 @@ return { - "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, _) - 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, - }, - }, - }) + "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, _) + 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/refactoring.lua b/.config/nvim/lua/plugins/refactoring.lua new file mode 100644 index 0000000..fe31a79 --- /dev/null +++ b/.config/nvim/lua/plugins/refactoring.lua @@ -0,0 +1,10 @@ +return { + "ThePrimeagen/refactoring.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("refactoring").setup() + end, +} diff --git a/.config/nvim/lua/plugins/scissors.lua b/.config/nvim/lua/plugins/scissors.lua index 4e4d05f..13dd72a 100644 --- a/.config/nvim/lua/plugins/scissors.lua +++ b/.config/nvim/lua/plugins/scissors.lua @@ -1,8 +1,8 @@ return { - "chrisgrieser/nvim-scissors", - event = "VeryLazy", - dependencies = "nvim-telescope/telescope.nvim", - opts = { - snippetDir = "~/.config/nvim/snippets", - } + "chrisgrieser/nvim-scissors", + event = "VeryLazy", + 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 593ba02..75f6e1c 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -1,181 +1,184 @@ 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 = {}, - 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, + "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, + }, + }, + }, + pickers = { + diagnostics = { + theme = "ivy", + initial_mode = "normal", + layout_config = { + preview_cutoff = 9999, + }, + }, + }, + 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", "ff", function() + builtin.live_grep({ hidden = true }) + end, {}) + + 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 002de08..01f1f93 100644 --- a/.config/nvim/lua/plugins/tmux.lua +++ b/.config/nvim/lua/plugins/tmux.lua @@ -1,19 +1,19 @@ return { - "aserowy/tmux.nvim", - config = function() - require("tmux").setup({ - copy_sync = { - enable = false - }, - navigation = { - cycle_navigation = true, - enable_default_keybindings = true, - persist_zoom = true, - }, - resize = { - -- enables default keybindings (A-hjkl) for normal mode - enable_default_keybindings = false, - }, - }) - end + "aserowy/tmux.nvim", + config = function() + require("tmux").setup({ + copy_sync = { + enable = false, + }, + navigation = { + cycle_navigation = true, + enable_default_keybindings = true, + persist_zoom = true, + }, + resize = { + -- enables default keybindings (A-hjkl) for normal mode + enable_default_keybindings = false, + }, + }) + end, } diff --git a/.config/nvim/lua/plugins/todo-comments.lua b/.config/nvim/lua/plugins/todo-comments.lua index 7f51c2b..a0151b7 100644 --- a/.config/nvim/lua/plugins/todo-comments.lua +++ b/.config/nvim/lua/plugins/todo-comments.lua @@ -1,15 +1,15 @@ return { - "folke/todo-comments.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - require('todo-comments').setup() + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require("todo-comments").setup() - vim.keymap.set('n', 'tt', function() - vim.cmd('TodoTelescope') - end, {}) + vim.keymap.set("n", "tt", function() + vim.cmd("TodoTelescope") + end, {}) - vim.keymap.set('n', 'tq', function() - vim.cmd('TodoQuickFix') - end, {}) - end + 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 04ebd87..37d169d 100644 --- a/.config/nvim/lua/plugins/trouble.lua +++ b/.config/nvim/lua/plugins/trouble.lua @@ -1,37 +1,47 @@ return { - "folke/trouble.nvim", - opts = {}, - cmd = "Trouble", - keys = { + "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)", + }, { - "xx", - "Trouble diagnostics toggle", - desc = "Diagnostics (Trouble)", - }, + "xj", + "Trouble diagnostics next", + desc = "Diagnostics Next (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)", - }, - }, + "xk", + "Trouble diagnostics prev", + desc = "Diagnostics Previous (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 3eb909c..a1bd08c 100644 --- a/.config/nvim/lua/plugins/undotree.lua +++ b/.config/nvim/lua/plugins/undotree.lua @@ -1,17 +1,17 @@ return { "mbbill/undotree", config = function() - if vim.fn.has("persistent_undo") == 0 then - return - end + if vim.fn.has("persistent_undo") == 0 then + return + end - local target_path = vim.fn.expand("~/.cache/nvim/undodir/") + 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 + 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 + vim.opt.undodir = target_path + vim.opt.undofile = true end, } diff --git a/.config/nvim/lua/plugins/vim-dadbod.lua b/.config/nvim/lua/plugins/vim-dadbod.lua index ca35ce2..daa4968 100644 --- a/.config/nvim/lua/plugins/vim-dadbod.lua +++ b/.config/nvim/lua/plugins/vim-dadbod.lua @@ -1,23 +1,23 @@ return { - 'kristijanhusak/vim-dadbod-ui', - dependencies = { - { - 'tpope/vim-dadbod', - lazy = true, - }, - { - 'kristijanhusak/vim-dadbod-completion', - ft = { 'sql', 'mysql', 'plsql' }, - lazy = true, - }, - }, - cmd = { - 'DBUI', - 'DBUIToggle', - 'DBUIAddConnection', - 'DBUIFindBuffer', - }, - init = function() - vim.g.db_ui_use_nerd_fonts = 1 - end, + "kristijanhusak/vim-dadbod-ui", + dependencies = { + { + "tpope/vim-dadbod", + lazy = true, + }, + { + "kristijanhusak/vim-dadbod-completion", + ft = { "sql", "mysql", "plsql" }, + lazy = true, + }, + }, + cmd = { + "DBUI", + "DBUIToggle", + "DBUIAddConnection", + "DBUIFindBuffer", + }, + init = function() + vim.g.db_ui_use_nerd_fonts = 1 + end, } diff --git a/.zshrc b/.zshrc index 3bd9347..da16afc 100644 --- a/.zshrc +++ b/.zshrc @@ -21,7 +21,7 @@ export EDITOR=nvim export GIT_EDITOR=nvim export PATH="${HOME}/.local/bin/:${HOME}/go/bin:${HOME}/.cargo/bin:${PATH}" -export DOCKER_DEFAULT_PLATFORM=linux/amd64 +# export DOCKER_DEFAULT_PLATFORM=linux/amd64 # Enable substitution in the prompt. setopt prompt_subst