From dc228a038b0cf6d89ad42d0f14bd9ecd4a955f69 Mon Sep 17 00:00:00 2001 From: Kiruel Date: Tue, 17 Jun 2025 23:49:59 +0200 Subject: [PATCH] chore: save config --- init.lua | 99 +++++++++-- lua/custom/plugins/avante.lua.skip | 169 ++++++++++++++++++ lua/custom/plugins/codesnap.lua | 11 ++ lua/custom/plugins/dignostics.lua | 71 ++++++-- lua/custom/plugins/flutter.lua | 25 ++- lua/custom/plugins/harpoon.lua | 24 +++ lua/custom/plugins/mason.lua | 40 +++++ lua/custom/plugins/nvim-jdtls.lua.skip | 208 +++++++++++++++++++++++ lua/custom/plugins/springboot.lua.skip | 15 ++ lua/custom/plugins/telescope.lua | 92 ++++++++-- lua/custom/plugins/tests.lua | 8 +- lua/custom/plugins/tree.lua | 1 + lua/custom/plugins/xcode-config.lua.skip | 16 ++ lua/kickstart/plugins/autoformat.lua | 2 +- lua/kickstart/plugins/debug.lua | 74 ++++---- snippets/dart.snippets | 15 ++ 16 files changed, 779 insertions(+), 91 deletions(-) create mode 100644 lua/custom/plugins/avante.lua.skip create mode 100644 lua/custom/plugins/codesnap.lua create mode 100644 lua/custom/plugins/harpoon.lua create mode 100644 lua/custom/plugins/mason.lua create mode 100644 lua/custom/plugins/nvim-jdtls.lua.skip create mode 100644 lua/custom/plugins/springboot.lua.skip create mode 100644 lua/custom/plugins/xcode-config.lua.skip diff --git a/init.lua b/init.lua index d6863382..007c5181 100644 --- a/init.lua +++ b/init.lua @@ -42,6 +42,7 @@ P.S. You can delete this when you're done too. It's your config now :) vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' +vim.opt.textwidth = 80 -- Install package manager -- https://github.com/folke/lazy.nvim -- `:help lazy.nvim.txt` for more info @@ -218,6 +219,10 @@ vim.o.smartcase = true -- Keep signcolumn on by default vim.wo.signcolumn = 'yes' +-- Cursor UI +vim.opt.cursorline = true +-- vim.opt.guicursor = "i:block-blinkwait1000-blinkon500-blinkoff500"; + -- Decrease update time vim.o.updatetime = 100 vim.o.timeoutlen = 100 @@ -229,7 +234,6 @@ vim.o.completeopt = 'menuone,noselect' -- NOTE: You should make sure your terminal supports this vim.o.termguicolors = true - -- [[ Basic Keymaps ]] -- Keymaps for better default experience @@ -240,6 +244,7 @@ vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + -- [[ Highlight on yank ]] -- See `:help vim.highlight.on_yank()` local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) @@ -269,8 +274,8 @@ vim.filetype.add({ -- See `:help nvim-treesitter` require('nvim-treesitter.configs').setup { -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', - 'dart', 'prisma', 'graphql', 'json', 'markdown' }, + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'ruby', + 'dart', 'prisma', 'graphql', 'json', 'markdown', 'kotlin', 'terraform' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = false, @@ -335,6 +340,10 @@ require('nvim-treesitter.configs').setup { vim.api.nvim_set_keymap('i', 'kj', '', { noremap = true }) +-- Git +vim.keymap.set('n', 'Go', 'GitConflictChooseOurs', { desc = '[G]it Conflict Choose [o]urs' }) +vim.keymap.set('n', 'Gt', 'GitConflictChooseTheirs', { desc = '[G]it Conflict Choose [t]heirs' }) + -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) @@ -353,7 +362,7 @@ vim.keymap.set("n", "vs", "vs", { desc = "[V]ertical [S]plit" } vim.keymap.set("n", "s", 'w', { desc = "[S]ave file" }) -- Quit from terminal -vim.api.nvim_set_keymap('t', '', '', { noremap = true }) +-- vim.api.nvim_set_keymap('t', '', '', { noremap = true }) -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_, bufnr) -- NOTE: Remember that lua is a real programming language, and as such it is possible @@ -371,7 +380,7 @@ local on_attach = function(_, bufnr) end nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + nmap('c', vim.lsp.buf.code_action, '[C]ode [A]ction') nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') @@ -411,10 +420,12 @@ local servers = { -- gopls = {}, -- pyright = {}, -- rust_analyzer = {} - tsserver = {}, + ts_ls = {}, prismals = {}, graphql = {}, clangd = {}, + terraformls = {}, + kotlin_language_server = {}, -- prettierd = {}, -- html = { filetypes = { 'html', 'twig', 'hbs'} } lua_ls = { @@ -471,23 +482,77 @@ vim.api.nvim_create_autocmd('LspAttach', { }) -- Ensure the servers above are installed -local mason_lspconfig = require 'mason-lspconfig' +local mason_lspconfig = require('mason-lspconfig') local lspconfig = require('lspconfig') mason_lspconfig.setup { ensure_installed = vim.tbl_keys(servers), + automatic_enable = false } -mason_lspconfig.setup_handlers { - function(server_name) - lspconfig[server_name].setup { - capabilities = capabilities, - on_attach = on_attach, - settings = servers[server_name], - filetypes = (servers[server_name] or {}).filetypes, - } - end -} +-- mason_lspconfig.setup_handlers { +-- function(server_name) +-- lspconfig[server_name].setup { +-- capabilities = capabilities, +-- on_attach = on_attach, +-- settings = servers[server_name], +-- filetypes = (servers[server_name] or {}).filetypes, +-- automatic_enable = false +-- } +-- end +-- } + +lspconfig.gopls.setup({ + on_attach = on_attach, + capabilities = capabilities, + settings = { + gopls = { + ["ui.inlayhint.hints"] = { + compositeLiteralFields = true, + constantValues = true, + parameterNames = true, + }, + }, + }, +}) + +lspconfig.lua_ls.setup({ + capabilities = capabilities, + on_attach = on_attach, + settings = { + Lua = { + telemetry = { + enable = false, + }, + }, + }, + on_init = function(client) + if client.workspace_folders then + local path = client.workspace_folders[1].name + if + path ~= vim.fn.stdpath("config") + and (vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc")) + then + return + end + end + client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { + runtime = { + version = "LuaJIT", + }, + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME, + "${3rd}/luv/library", + }, + }, + }) + end, +}) + +require("mason").setup() +require("mason-lspconfig").setup() capabilities.textDocument.completion.completionItem.snippetSupport = true -- lspconfig.dartls.setup({ diff --git a/lua/custom/plugins/avante.lua.skip b/lua/custom/plugins/avante.lua.skip new file mode 100644 index 00000000..3a814fb7 --- /dev/null +++ b/lua/custom/plugins/avante.lua.skip @@ -0,0 +1,169 @@ +return { + "yetone/avante.nvim", + event = "VeryLazy", + lazy = false, + version = false, -- set this if you want to always pull the latest change + opts = { + -- add any opts here + }, + config = function() + require('avante').setup({ + -- provider = "ollama", + -- vendors = { + -- ollama = { + -- __inherited_from = "openai", + -- api_key_name = "", + -- endpoint = "http://127.0.0.1:11434/v1", + -- model = "mistral", + -- }, + -- }, + provider = "claude", -- Recommend using Claude + auto_suggestions_provider = "claude", -- Since auto-suggestions are a high-frequency operation and therefore expensive, it is recommended to specify an inexpensive provider or even a free provider: copilot + claude = { + endpoint = "https://api.anthropic.com", + model = "claude-3-5-sonnet-20241022", + temperature = 0, + max_tokens = 4096, + }, + -- claude = { + -- endpoint = "https://api.anthropic.com", + -- model = "claude-3-5-sonnet-20241022", + -- temperature = 0, + -- max_tokens = 4096, + -- }, + ---Specify the special dual_boost mode + ---1. enabled: Whether to enable dual_boost mode. Default to false. + ---2. first_provider: The first provider to generate response. Default to "openai". + ---3. second_provider: The second provider to generate response. Default to "claude". + ---4. prompt: The prompt to generate response based on the two reference outputs. + ---5. timeout: Timeout in milliseconds. Default to 60000. + ---How it works: + --- When dual_boost is enabled, avante will generate two responses from the first_provider and second_provider respectively. Then use the response from the first_provider as provider1_output and the response from the second_provider as provider2_output. Finally, avante will generate a response based on the prompt and the two reference outputs, with the default Provider as normal. + ---Note: This is an experimental feature and may not work as expected. + dual_boost = { + enabled = false, + first_provider = "openai", + second_provider = "claude", + prompt = + "Based on the two reference outputs below, generate a response that incorporates elements from both but reflects your own judgment and unique perspective. Do not provide any explanation, just give the response directly. Reference Output 1: [{{provider1_output}}], Reference Output 2: [{{provider2_output}}]", + timeout = 60000, -- Timeout in milliseconds + }, + behaviour = { + auto_suggestions = true, -- Experimental stage + auto_set_highlight_group = true, + auto_set_keymaps = true, + auto_apply_diff_after_generation = false, + support_paste_from_clipboard = false, + minimize_diff = true, -- Whether to remove unchanged lines when applying a code block + }, + mappings = { + diff = { + ours = "co", + theirs = "ct", + all_theirs = "ca", + both = "cb", + cursor = "cc", + next = "]x", + prev = "[x", + }, + suggestion = { + accept = "", + next = "", + prev = "", + dismiss = "", + }, + jump = { + next = "]]", + prev = "[[", + }, + submit = { + normal = "", + insert = "", + }, + sidebar = { + apply_all = "A", + apply_cursor = "a", + switch_windows = "", + reverse_switch_windows = "", + }, + }, + hints = { enabled = true }, + windows = { + ---@type "right" | "left" | "top" | "bottom" + position = "right", -- the position of the sidebar + wrap = true, -- similar to vim.o.wrap + width = 30, -- default % based on available width + sidebar_header = { + enabled = true, -- true, false to enable/disable the header + align = "center", -- left, center, right for title + rounded = true, + }, + input = { + prefix = "> ", + height = 8, -- Height of the input window in vertical layout + }, + edit = { + border = "rounded", + start_insert = true, -- Start insert mode when opening the edit window + }, + ask = { + floating = false, -- Open the 'AvanteAsk' prompt in a floating window + start_insert = true, -- Start insert mode when opening the ask window + border = "rounded", + focus_on_apply = "ours", -- which diff to focus after applying + }, + }, + highlights = { + diff = { + current = "DiffText", + incoming = "DiffAdd", + }, + }, + diff = { + autojump = true, + list_opener = "copen", + --- Override the 'timeoutlen' setting while hovering over a diff (see :help timeoutlen). + --- Helps to avoid entering operator-pending mode with diff mappings starting with `c`. + --- Disable by setting to -1. + override_timeoutlen = 500, + }, + }) + end, + -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` + build = "make", + -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows + dependencies = { + "stevearc/dressing.nvim", + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + --- The below dependencies are optional, + "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions + "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons + "zbirenbaum/copilot.lua", -- for providers='copilot' + { + -- support for image pasting + "HakonHarnes/img-clip.nvim", + event = "VeryLazy", + opts = { + -- recommended settings + default = { + embed_image_as_base64 = false, + prompt_for_file_name = false, + drag_and_drop = { + insert_mode = true, + }, + -- required for Windows users + use_absolute_path = true, + }, + }, + }, + { + -- Make sure to set this up properly if you have lazy=true + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { "markdown", "Avante" }, + }, + ft = { "markdown", "Avante" }, + }, + }, +} diff --git a/lua/custom/plugins/codesnap.lua b/lua/custom/plugins/codesnap.lua new file mode 100644 index 00000000..7eb72792 --- /dev/null +++ b/lua/custom/plugins/codesnap.lua @@ -0,0 +1,11 @@ +return { + "mistricky/codesnap.nvim", + build = "make", + config = function() + require("codesnap").setup({ + save_path = "~/Pictures", + watermark = "", + }) + end, + +} diff --git a/lua/custom/plugins/dignostics.lua b/lua/custom/plugins/dignostics.lua index 3ddaa962..f63c4302 100644 --- a/lua/custom/plugins/dignostics.lua +++ b/lua/custom/plugins/dignostics.lua @@ -1,19 +1,62 @@ +-- return { +-- "folke/trouble.nvim", +-- dependencies = { "nvim-tree/nvim-web-devicons" }, +-- opts = { +-- -- your configuration comes here +-- -- or leave it empty to use the default settings +-- -- refer to the configuration section below +-- }, +-- config = function() +-- vim.keymap.set("n", "xx", function() require("trouble").toggle() end) +-- vim.keymap.set("n", "xw", function() require("trouble").toggle("workspace_diagnostics") end) +-- vim.keymap.set("n", "xd", function() require("trouble").toggle("document_diagnostics") end) +-- vim.keymap.set("n", "xq", function() require("trouble").toggle("quickfix") end) +-- vim.keymap.set("n", "xl", function() require("trouble").toggle("loclist") end) +-- vim.keymap.set("n", "xn", function() require("trouble").next({ skip_groups = true, jump = true }) end) +-- vim.keymap.set("n", "xb", function() require("trouble").previous({ skip_groups = true, jump = true }) end) +-- vim.keymap.set("n", "gR", function() require("trouble").toggle("lsp_references") end) +-- end +-- } return { "folke/trouble.nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = "Trouble", + keys = { + { + "xx", + "Trouble diagnostics toggle", + desc = "Diagnostics (Trouble)", + }, + { + "xn", + "lua require(\"trouble\").next({ skip_groups = true, jump = true })", + desc = "Diagnostics Next" + }, + { + "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)", + } }, - config = function() - vim.keymap.set("n", "xx", function() require("trouble").toggle() end) - vim.keymap.set("n", "xw", function() require("trouble").toggle("workspace_diagnostics") end) - vim.keymap.set("n", "xd", function() require("trouble").toggle("document_diagnostics") end) - vim.keymap.set("n", "xq", function() require("trouble").toggle("quickfix") end) - vim.keymap.set("n", "xl", function() require("trouble").toggle("loclist") end) - vim.keymap.set("n", "xn", function() require("trouble").next({ skip_groups = true, jump = true }) end) - vim.keymap.set("n", "xb", function() require("trouble").previous({ skip_groups = true, jump = true }) end) - vim.keymap.set("n", "gR", function() require("trouble").toggle("lsp_references") end) - end } diff --git a/lua/custom/plugins/flutter.lua b/lua/custom/plugins/flutter.lua index 83ea154c..6a2b7a8d 100644 --- a/lua/custom/plugins/flutter.lua +++ b/lua/custom/plugins/flutter.lua @@ -1,6 +1,7 @@ return { 'akinsho/flutter-tools.nvim', lazy = false, + branch = 'main', dependencies = { 'nvim-lua/plenary.nvim', 'stevearc/dressing.nvim', -- optional for vim.ui.select @@ -27,15 +28,19 @@ return { project_config = true, } }, - debugger = { -- integrate with nvim dap + install dart code debugger + debugger = { -- integrate with nvim dap + install dart code debugger enabled = true, - run_via_dap = false, -- use dap instead of a plenary job to run flutter apps + register_configurations = function(_) + require("dap").configurations.dart = {} + require("dap.ext.vscode").load_launchjs() + end, + run_via_dap = true, -- use dap instead of a plenary job to run flutter apps -- if empty dap will not stop on any exceptions, otherwise it will stop on those specified -- see |:help dap.set_exception_breakpoints()| for more info - exception_breakpoints = {} }, root_patterns = { ".git", "pubspec.yaml" }, -- patterns to find the root of your flutter project - fvm = true, -- takes priority over path, uses /.fvm/flutter_sdk if enabled + -- root_patterns = { ".git", "youfeel_flutter/pubspec.yaml" }, -- patterns to find the root of your flutter project + fvm = false, -- takes priority over path, uses /.fvm/flutter_sdk if enabled widget_guides = { enabled = false, }, @@ -45,7 +50,7 @@ return { enabled = true -- set to false to disable }, dev_log = { - enabled = true, + enabled = false, notify_errors = false, -- if there is an error whilst running then notify the user open_cmd = "tabedit", -- command to us }, @@ -81,19 +86,23 @@ return { -- enableSnippets = true, previewLsp = true, updateImportsOnRename = true, -- Whether to update imports and other directives when files are renamed. Required for `FlutterRename` command. + lineLength = vim.o.textwidth, } } } + -- [[ Configure Flutter tools]] - vim.keymap.set('n', 'r', require('telescope').extensions.flutter.commands, { desc = 'Open command Flutter' }) + vim.keymap.set('n', 'r', function() + require('telescope').extensions.flutter.commands() + end, { desc = 'Open command Flutter' }) vim.keymap.set('n', 'br', function() vim.cmd('20new') - vim.cmd('te fvm flutter packages pub run build_runner build --delete-conflicting-outputs') + vim.cmd('te dart run build_runner build --delete-conflicting-outputs && exit') vim.cmd('2sleep | normal G') end) vim.keymap.set('n', 'bt', function() vim.cmd('20new') - vim.cmd('te sh scripts/create_clean_lcov_and_generate_html.sh') + vim.cmd('te flutter test') vim.cmd('2sleep | normal G') end) -- '20new | te fvm flutter pub get && fvm flutter packages pub run build_runner build --delete-conflicting-outputs | $') diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000..56f7139a --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,24 @@ +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local harpoon = require("harpoon") + + -- REQUIRED + harpoon:setup() + -- REQUIRED + + vim.keymap.set("n", "k", function() harpoon:list():add() end, { desc = 'Harpoon add to list' }) + vim.keymap.set("n", "", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) + + vim.keymap.set("n", "", function() harpoon:list():select(1) end) + vim.keymap.set("n", "", function() harpoon:list():select(2) end) + vim.keymap.set("n", "", function() harpoon:list():select(3) end) + vim.keymap.set("n", "", function() harpoon:list():select(4) end) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set("n", "", function() harpoon:list():prev() end) + vim.keymap.set("n", "", function() harpoon:list():next() end) + end, +} diff --git a/lua/custom/plugins/mason.lua b/lua/custom/plugins/mason.lua new file mode 100644 index 00000000..3ff8a9ad --- /dev/null +++ b/lua/custom/plugins/mason.lua @@ -0,0 +1,40 @@ +return { + "williamboman/mason.nvim", + dependencies = { + "WhoIsSethDaniel/mason-tool-installer.nvim", + }, + config = function() + local mason = require("mason") + + local mason_tool_installer = require("mason-tool-installer") + + -- enable mason and configure icons + mason.setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, + }) + + mason_tool_installer.setup({ + ensure_installed = { + "standardrb", + "prettier", + "prettierd", + "ktlint", + "eslint_d", + "google-java-format", + "htmlbeautifier", + "beautysh", + "buf", + "rustfmt", + "yamlfix", + "taplo", + "shellcheck", + }, + }) + end, +} diff --git a/lua/custom/plugins/nvim-jdtls.lua.skip b/lua/custom/plugins/nvim-jdtls.lua.skip new file mode 100644 index 00000000..272bdbb3 --- /dev/null +++ b/lua/custom/plugins/nvim-jdtls.lua.skip @@ -0,0 +1,208 @@ +return { + "mfussenegger/nvim-jdtls", + dependencies = { "folke/which-key.nvim" }, + ft = java_filetypes, + opts = function() + local mason_registry = require("mason-registry") + local lombok_jar = mason_registry.get_package("jdtls"):get_install_path() .. "/lombok.jar" + return { + -- How to find the root dir for a given filename. The default comes from + -- lspconfig which provides a function specifically for java projects. + root_dir = LazyVim.lsp.get_raw_config("jdtls").default_config.root_dir, + + -- How to find the project name for a given root dir. + project_name = function(root_dir) + return root_dir and vim.fs.basename(root_dir) + end, + + -- Where are the config and workspace dirs for a project? + jdtls_config_dir = function(project_name) + return vim.fn.stdpath("cache") .. "/jdtls/" .. project_name .. "/config" + end, + jdtls_workspace_dir = function(project_name) + return vim.fn.stdpath("cache") .. "/jdtls/" .. project_name .. "/workspace" + end, + + -- How to run jdtls. This can be overridden to a full java command-line + -- if the Python wrapper script doesn't suffice. + cmd = { + vim.fn.exepath("jdtls"), + string.format("--jvm-arg=-javaagent:%s", lombok_jar), + }, + full_cmd = function(opts) + local fname = vim.api.nvim_buf_get_name(0) + local root_dir = opts.root_dir(fname) + local project_name = opts.project_name(root_dir) + local cmd = vim.deepcopy(opts.cmd) + if project_name then + vim.list_extend(cmd, { + "-configuration", + opts.jdtls_config_dir(project_name), + "-data", + opts.jdtls_workspace_dir(project_name), + }) + end + return cmd + end, + + -- These depend on nvim-dap, but can additionally be disabled by setting false here. + dap = { hotcodereplace = "auto", config_overrides = {} }, + dap_main = {}, + test = true, + settings = { + java = { + inlayHints = { + parameterNames = { + enabled = "all", + }, + }, + }, + }, + } + end, + config = function(_, opts) + -- Find the extra bundles that should be passed on the jdtls command-line + -- if nvim-dap is enabled with java debug/test. + local mason_registry = require("mason-registry") + local bundles = {} ---@type string[] + if opts.dap and LazyVim.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then + local java_dbg_pkg = mason_registry.get_package("java-debug-adapter") + local java_dbg_path = java_dbg_pkg:get_install_path() + local jar_patterns = { + java_dbg_path .. "/extension/server/com.microsoft.java.debug.plugin-*.jar", + } + -- java-test also depends on java-debug-adapter. + if opts.test and mason_registry.is_installed("java-test") then + local java_test_pkg = mason_registry.get_package("java-test") + local java_test_path = java_test_pkg:get_install_path() + vim.list_extend(jar_patterns, { + java_test_path .. "/extension/server/*.jar", + }) + end + for _, jar_pattern in ipairs(jar_patterns) do + for _, bundle in ipairs(vim.split(vim.fn.glob(jar_pattern), "\n")) do + table.insert(bundles, bundle) + end + end + end + + local function attach_jdtls() + local fname = vim.api.nvim_buf_get_name(0) + + -- Configuration can be augmented and overridden by opts.jdtls + local config = extend_or_override({ + cmd = opts.full_cmd(opts), + root_dir = opts.root_dir(fname), + init_options = { + bundles = bundles, + }, + settings = opts.settings, + -- enable CMP capabilities + capabilities = LazyVim.has("cmp-nvim-lsp") and require("cmp_nvim_lsp").default_capabilities() or nil, + }, opts.jdtls) + + -- Existing server will be reused if the root_dir matches. + require("jdtls").start_or_attach(config) + -- not need to require("jdtls.setup").add_commands(), start automatically adds commands + end + + -- Attach the jdtls for each java buffer. HOWEVER, this plugin loads + -- depending on filetype, so this autocmd doesn't run for the first file. + -- For that, we call directly below. + vim.api.nvim_create_autocmd("FileType", { + pattern = java_filetypes, + callback = attach_jdtls, + }) + + -- Setup keymap and dap after the lsp is fully attached. + -- https://github.com/mfussenegger/nvim-jdtls#nvim-dap-configuration + -- https://neovim.io/doc/user/lsp.html#LspAttach + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client and client.name == "jdtls" then + local wk = require("which-key") + wk.add({ + { + mode = "n", + buffer = args.buf, + { "cx", group = "extract" }, + { "cxv", require("jdtls").extract_variable_all, desc = "Extract Variable" }, + { "cxc", require("jdtls").extract_constant, desc = "Extract Constant" }, + { "gs", require("jdtls").super_implementation, desc = "Goto Super" }, + { "gS", require("jdtls.tests").goto_subjects, desc = "Goto Subjects" }, + { "co", require("jdtls").organize_imports, desc = "Organize Imports" }, + }, + }) + wk.add({ + { + mode = "v", + buffer = args.buf, + { "cx", group = "extract" }, + { + "cxm", + [[lua require('jdtls').extract_method(true)]], + desc = "Extract Method", + }, + { + "cxv", + [[lua require('jdtls').extract_variable_all(true)]], + desc = "Extract Variable", + }, + { + "cxc", + [[lua require('jdtls').extract_constant(true)]], + desc = "Extract Constant", + }, + }, + }) + + if opts.dap and LazyVim.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then + -- custom init for Java debugger + require("jdtls").setup_dap(opts.dap) + require("jdtls.dap").setup_dap_main_class_configs(opts.dap_main) + + -- Java Test require Java debugger to work + if opts.test and mason_registry.is_installed("java-test") then + -- custom keymaps for Java test runner (not yet compatible with neotest) + wk.add({ + { + mode = "n", + buffer = args.buf, + { "t", group = "test" }, + { + "tt", + function() + require("jdtls.dap").test_class({ + config_overrides = type(opts.test) ~= "boolean" and opts.test.config_overrides or nil, + }) + end, + desc = "Run All Test", + }, + { + "tr", + function() + require("jdtls.dap").test_nearest_method({ + config_overrides = type(opts.test) ~= "boolean" and opts.test.config_overrides or nil, + }) + end, + desc = "Run Nearest Test", + }, + { "tT", require("jdtls.dap").pick_test, desc = "Run Test" }, + }, + }) + end + end + + -- User can set additional keymaps in opts.on_attach + if opts.on_attach then + opts.on_attach(args) + end + end + end, + }) + + -- Avoid race condition by calling attach the first time, since the autocmd won't fire. + attach_jdtls() + end, +} diff --git a/lua/custom/plugins/springboot.lua.skip b/lua/custom/plugins/springboot.lua.skip new file mode 100644 index 00000000..b2096088 --- /dev/null +++ b/lua/custom/plugins/springboot.lua.skip @@ -0,0 +1,15 @@ +return { + "elmcgill/springboot-nvim", + depedencies = { + "neovim/nvim-lspconfig", + "mfussenegger/nvim-jdtls" + }, + config = function() + local springboot_nvim = require("springboot-nvim") + vim.keymap.set('n', 'Jr', springboot_nvim.boot_run, { desc = "Spring Boot Run Project" }) + vim.keymap.set('n', 'Jc', springboot_nvim.generate_class, { desc = "Java Create Class" }) + vim.keymap.set('n', 'Ji', springboot_nvim.generate_interface, { desc = "Java Create Interface" }) + vim.keymap.set('n', 'Je', springboot_nvim.generate_enum, { desc = "Java Create Enum" }) + springboot_nvim.setup({}) + end +} diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua index f74e1019..5708f3a0 100644 --- a/lua/custom/plugins/telescope.lua +++ b/lua/custom/plugins/telescope.lua @@ -19,6 +19,16 @@ return { config = function() require('telescope').setup { defaults = { + file_ignore_patterns = { + "node_modules/.*", + "%.env", + "yarn.lock", + "package-lock.json", + "lazy-lock.json", + "init.sql", + "target/.*", + ".git/.*", + }, mappings = { i = { [''] = false, @@ -32,30 +42,84 @@ return { pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'flutter') + builtin = require('telescope.builtin'); + -- See `:help telescope.builtin` - vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) - vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', '?', builtin.oldfiles, { desc = '[?] Find recently opened files' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) vim.keymap.set('n', '/', function() -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { winblend = 10, previewer = false, }) end, { desc = '[/] Fuzzily search in current buffer' }) - vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) - vim.keymap.set('n', 'gs', require('telescope.builtin').git_status, { desc = 'Search [G]it [S]tatus' }) - vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'gi', require('telescope.builtin').lsp_implementations, + vim.keymap.set('n', 'gf', builtin.git_files, { desc = 'Search [G]it [F]iles' }) + vim.keymap.set('n', 'gs', builtin.git_status, { desc = 'Search [G]it [S]tatus' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'gi', builtin.lsp_implementations, { desc = '[G]o to [I]mplementations' }) - vim.keymap.set('n', 'gr', require('telescope.builtin').lsp_references, + vim.keymap.set('n', 'gr', builtin.lsp_references, { desc = '[G]o to [R]eferences' }) - vim.keymap.set('n', 'gd', require('telescope.builtin').lsp_definitions, + vim.keymap.set('n', 'gd', builtin.lsp_definitions, { desc = '[G]o to [D]efinitions' }) - vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + + + -- Harpoon config: + -- + + -- local harpoon = require('harpoon') + -- harpoon:setup({}) + -- + -- -- basic telescope configuration + -- local conf = require("telescope.config").values + -- + -- + -- local function toggle_telescope(harpoon_files) + -- local make_finder = function() + -- local paths = {} + -- for _, item in ipairs(harpoon_files.items) do + -- table.insert(paths, item.value) + -- end + -- + -- return require("telescope.finders").new_table({ + -- results = paths, + -- }) + -- end + -- + -- local file_paths = {} + -- for _, item in ipairs(harpoon_files.items) do + -- table.insert(file_paths, item.value) + -- end + -- + -- require("telescope.pickers").new({}, { + -- prompt_title = "Harpoon", + -- finder = make_finder(), + -- previewer = conf.file_previewer({}), + -- sorter = conf.generic_sorter({}), + -- attach_mappings = function(prompt_buffer_number, map) + -- map("n", "dd", function() + -- local state = require("telescope.actions.state") + -- local selected_entry = state.get_selected_entry() + -- local current_picker = state.get_current_picker(prompt_buffer_number) + -- + -- harpoon:list():removeAt(selected_entry.index) + -- current_picker:refresh(make_finder()) + -- end) + -- + -- return true + -- end, + -- + -- }):find() + -- end + -- + -- vim.keymap.set("n", "", function() toggle_telescope(harpoon:list()) end, + -- { desc = "Open harpoon window" }) end } diff --git a/lua/custom/plugins/tests.lua b/lua/custom/plugins/tests.lua index 00b86fc8..72b7a2ca 100644 --- a/lua/custom/plugins/tests.lua +++ b/lua/custom/plugins/tests.lua @@ -2,14 +2,13 @@ return { "nvim-neotest/neotest", dependencies = { "nvim-lua/plenary.nvim", - "antoinemadec/FixCursorHold.nvim", "sidlatau/neotest-dart" }, config = function() require('neotest').setup({ adapters = { require('neotest-dart') { - command = 'fvm flutter', -- Command being used to run tests. Defaults to `flutter` + command = 'flutter', -- Command being used to run tests. Defaults to `flutter` -- Change it to `fvm flutter` if using FVM -- change it to `dart` for Dart only tests use_lsp = true, -- When set Flutter outline information is used when constructing test name. @@ -29,6 +28,11 @@ return { end, { desc = 'Test: [T]oggle [O]utput' }) + vim.keymap.set('n', 'rtD', function() + -- neotest.run.run() + neotest.run.run({ strategy = 'dap' }) + end, { desc = 'Test: [R]un [T]ests' }) + vim.keymap.set('n', 'rt', function() neotest.run.run() end, { desc = 'Test: [R]un [T]ests' }) diff --git a/lua/custom/plugins/tree.lua b/lua/custom/plugins/tree.lua index c19c0113..3f9ddfae 100644 --- a/lua/custom/plugins/tree.lua +++ b/lua/custom/plugins/tree.lua @@ -124,6 +124,7 @@ return { window = { position = "left", width = 60, + auto_expand_width = false, mapping_options = { noremap = true, nowait = true, diff --git a/lua/custom/plugins/xcode-config.lua.skip b/lua/custom/plugins/xcode-config.lua.skip new file mode 100644 index 00000000..a40a042c --- /dev/null +++ b/lua/custom/plugins/xcode-config.lua.skip @@ -0,0 +1,16 @@ +return { + "wojciech-kulik/xcodebuild.nvim", + dependencies = { + -- "nvim-telescope/telescope.nvim", + -- "MunifTanjim/nui.nvim", + "folke/snacks.nvim", -- (optional) to show previews + -- "nvim-tree/nvim-tree.lua", -- (optional) to manage project files + "stevearc/oil.nvim", -- (optional) to manage project files + -- "nvim-treesitter/nvim-treesitter", -- (optional) for Quick tests support (required Swift parser) + }, + config = function() + require("xcodebuild").setup({ + -- put some options here or leave it empty to use default settings + }) + end, +} diff --git a/lua/kickstart/plugins/autoformat.lua b/lua/kickstart/plugins/autoformat.lua index bc56b15b..ed9c2563 100644 --- a/lua/kickstart/plugins/autoformat.lua +++ b/lua/kickstart/plugins/autoformat.lua @@ -46,7 +46,7 @@ return { -- Tsserver usually works poorly. Sorry you work with bad languages -- You can remove this line if you know what you're doing :) - if client.name == 'tsserver' then + if client.name == 'ts_ls' then return end diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 223a4863..1df69fa0 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -12,18 +12,16 @@ return { -- NOTE: And you can specify dependencies as well dependencies = { -- Creates a beautiful debugger UI - 'rcarriga/nvim-dap-ui', + -- 'rcarriga/nvim-dap-ui', + 'igorlfs/nvim-dap-view', -- Installs the debug adapters for you 'williamboman/mason.nvim', 'jay-babu/mason-nvim-dap.nvim', - - -- Add your own debuggers here - 'leoluz/nvim-dap-go', }, config = function() local dap = require 'dap' - local dapui = require 'dapui' + -- local dapui = require 'dapui' require('mason-nvim-dap').setup { -- Makes a best effort to setup the various debuggers with @@ -44,10 +42,12 @@ return { } -- Basic debugging keymaps, feel free to change to your liking! - vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) - vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) - vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) - vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) + vim.keymap.set('n', 'dt', dap.repl.open, { desc = 'Debug: Open repl' }) + vim.keymap.set('n', 'dtc', dap.repl.close, { desc = 'Debug: Close repl' }) + vim.keymap.set('n', 'dc', dap.continue, { desc = 'Debug: Start/Continue' }) + vim.keymap.set('n', 'dn', dap.step_into, { desc = 'Debug: Step Into' }) + vim.keymap.set('n', 'do', dap.step_over, { desc = 'Debug: Step Over' }) + vim.keymap.set('n', 'dO', dap.step_out, { desc = 'Debug: Step Out' }) vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) vim.keymap.set('n', 'B', function() dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') @@ -56,34 +56,38 @@ return { -- Dap UI setup -- For more information, see |:help nvim-dap-ui| - dapui.setup { - -- Set icons to characters that are more likely to work in every terminal. - -- Feel free to remove or use ones that you like more! :) - -- Don't feel like these are good choices. - icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, - controls = { - icons = { - pause = '⏸', - play = '▶', - step_into = '⏎', - step_over = '⏭', - step_out = '⏮', - step_back = 'b', - run_last = '▶▶', - terminate = '⏹', - disconnect = '⏏', - }, - }, - } + -- + -- local dapui = require("dapui") + -- dapui.setup { + -- -- Set icons to characters that are more likely to work in every terminal. + -- -- Feel free to remove or use ones that you like more! :) + -- -- Don't feel like these are good choices. + -- icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, + -- controls = { + -- icons = { + -- pause = '⏸', + -- play = '▶', + -- step_into = '⏎', + -- step_over = '⏭', + -- step_out = '⏮', + -- step_back = 'b', + -- run_last = '▶▶', + -- terminate = '⏹', + -- disconnect = '⏏', + -- }, + -- }, + -- } -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. - vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) + -- vim.keymap.set('n', 'dTo', dapui.open, { desc = 'Open: dap UI' }) + -- vim.keymap.set('n', 'dTc', dapui.close, { desc = 'Close: dap UI' }) + -- + -- dap.listeners.after.event_initialized['dapui_config'] = dapui.open + -- dap.listeners.before.event_terminated['dapui_config'] = dapui.close + -- dap.listeners.before.event_exited['dapui_config'] = dapui.close + -- + local dapview = require('dap-view') - dap.listeners.after.event_initialized['dapui_config'] = dapui.open - dap.listeners.before.event_terminated['dapui_config'] = dapui.close - dap.listeners.before.event_exited['dapui_config'] = dapui.close - - -- Install golang specific config - require('dap-go').setup() + vim.keymap.set('n', 'dTo', dapview.toggle, { desc = 'Open: dap UI' }) end, } diff --git a/snippets/dart.snippets b/snippets/dart.snippets index a9da30b5..d56b120d 100644 --- a/snippets/dart.snippets +++ b/snippets/dart.snippets @@ -12,3 +12,18 @@ snippet phr "AppLocalizations" AppLocalizations.of(context)!.$1 snippet imploc "Import AppLocalizations" import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +snippet gap "Create a gap with const" + const Gap($1), +snippet useEffect "Create an empty useEffect" + useEffect(() { + $1 + return; + }, []); +snippet clm "Create column with empty children" + Column(children: [ + $1 + ],) +snippet row "Create row with empty children" + Row(children: [ + $1 + ],)