From 6260524b90c7425ca8847652391fd70089381c9b Mon Sep 17 00:00:00 2001 From: Guust Taillieu Date: Sun, 7 Dec 2025 12:12:09 +0100 Subject: [PATCH] update --- ftplugin/java.lua | 157 ++++++++++++++++++++++ init.lua | 1 - lazy-lock.json | 41 +++--- lua/custom/after/transparency.lua | 76 +++++------ lua/custom/plugins/harpoon.lua | 76 +++++++++++ lua/custom/plugins/noice.lua | 8 -- lua/custom/plugins/notify.lua | 22 +++ lua/custom/plugins/oil.lua | 1 - lua/custom/plugins/trouble.lua | 10 ++ lua/custom/snippets/elexir.lua | 11 ++ lua/custom/snippets/kotlin.lua | 33 +++++ lua/kickstart/plugins/auto-completion.lua | 26 +--- lua/kickstart/plugins/format.lua | 8 ++ lua/kickstart/plugins/lsp/jdtls.lua | 5 + lua/kickstart/plugins/lsp/main-lsp.lua | 143 +++++++------------- lua/kickstart/plugins/lualine.lua | 2 +- lua/kickstart/plugins/mini.lua | 20 +-- lua/kickstart/plugins/snippets.lua | 51 +++++++ lua/kickstart/plugins/treesitter.lua | 12 ++ 19 files changed, 499 insertions(+), 204 deletions(-) create mode 100644 ftplugin/java.lua create mode 100644 lua/custom/plugins/harpoon.lua delete mode 100644 lua/custom/plugins/noice.lua create mode 100644 lua/custom/plugins/notify.lua create mode 100644 lua/custom/snippets/elexir.lua create mode 100644 lua/custom/snippets/kotlin.lua create mode 100644 lua/kickstart/plugins/lsp/jdtls.lua create mode 100644 lua/kickstart/plugins/snippets.lua diff --git a/ftplugin/java.lua b/ftplugin/java.lua new file mode 100644 index 00000000..5b42dbf3 --- /dev/null +++ b/ftplugin/java.lua @@ -0,0 +1,157 @@ +-- JDTLS (Java LSP) configuration +local home = vim.env.HOME -- Get the home directory + +local jdtls = require 'jdtls' +local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t') +local workspace_dir = home .. '/jdtls-workspace/' .. project_name + +local system_os = '' + +-- Determine OS +if vim.fn.has 'mac' == 1 then + system_os = 'mac' +elseif vim.fn.has 'unix' == 1 then + system_os = 'linux' +elseif vim.fn.has 'win32' == 1 or vim.fn.has 'win64' == 1 then + system_os = 'win' +else + print "OS not found, defaulting to 'linux'" + system_os = 'linux' +end + +-- Needed for debugging +local bundles = { + vim.fn.glob(home .. '/.local/share/nvim/mason/share/java-debug-adapter/com.microsoft.java.debug.plugin.jar'), +} + +-- Needed for running/debugging unit tests +vim.list_extend(bundles, vim.split(vim.fn.glob(home .. '/.local/share/nvim/mason/share/java-test/*.jar', 1), '\n')) + +-- See `:help vim.lsp.start_client` for an overview of the supported `config` options. +local config = { + -- The command that starts the language server + -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line + cmd = { + 'java', + '-Declipse.application=org.eclipse.jdt.ls.core.id1', + '-Dosgi.bundles.defaultStartLevel=4', + '-Declipse.product=org.eclipse.jdt.ls.core.product', + '-Dlog.protocol=true', + '-Dlog.level=ALL', + '-javaagent:' .. home .. '/.local/share/nvim/mason/share/jdtls/lombok.jar', + '-Xmx4g', + '--add-modules=ALL-SYSTEM', + '--add-opens', + 'java.base/java.util=ALL-UNNAMED', + '--add-opens', + 'java.base/java.lang=ALL-UNNAMED', + + -- Eclipse jdtls location + '-jar', + home .. '/.local/share/nvim/mason/share/jdtls/plugins/org.eclipse.equinox.launcher.jar', + '-configuration', + home .. '/.local/share/nvim/mason/packages/jdtls/config_' .. system_os, + '-data', + workspace_dir, + }, + + -- This is the default if not provided, you can remove it. Or adjust as needed. + -- One dedicated LSP server & client will be started per unique root_dir + root_dir = require('jdtls.setup').find_root { '.git', 'mvnw', 'pom.xml', 'build.gradle' }, + + -- Here you can configure eclipse.jdt.ls specific settings + -- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request + settings = { + java = { + -- TODO Replace this with the absolute path to your main java version (JDTLS requires JDK 21 or higher) + home = '/usr/lib/jvm/java-21-openjdk', + eclipse = { + downloadSources = true, + }, + configuration = { + updateBuildConfiguration = 'interactive', + -- TODO Update this by adding any runtimes that you need to support your Java projects and removing any that you don't have installed + -- The runtimes' name parameter needs to match a specific Java execution environments. See https://github.com/eclipse-jdtls/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request and search "ExecutionEnvironment". + runtimes = { + { + name = 'JavaSE-21', + path = '/usr/lib/jvm/java-21-openjdk', + }, + { + name = 'JavaSE-25', + path = '/usr/lib/jvm/java-25-openjdk', + }, + }, + }, + maven = { + downloadSources = true, + }, + implementationsCodeLens = { + enabled = true, + }, + referencesCodeLens = { + enabled = true, + }, + references = { + includeDecompiledSources = true, + }, + signatureHelp = { enabled = true }, + format = { + enabled = true, + -- Formatting works by default, but you can refer to a specific file/URL if you choose + -- settings = { + -- url = "https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml", + -- profile = "GoogleStyle", + -- }, + }, + completion = { + favoriteStaticMembers = { + 'org.hamcrest.MatcherAssert.assertThat', + 'org.hamcrest.Matchers.*', + 'org.hamcrest.CoreMatchers.*', + 'org.junit.jupiter.api.Assertions.*', + 'java.util.Objects.requireNonNull', + 'java.util.Objects.requireNonNullElse', + 'org.mockito.Mockito.*', + }, + importOrder = { + 'java', + 'javax', + 'com', + 'org', + }, + }, + sources = { + organizeImports = { + starThreshold = 9999, + staticStarThreshold = 9999, + }, + }, + codeGeneration = { + toString = { + template = '${object.className}{${member.name()}=${member.value}, ${otherMembers}}', + }, + useBlocks = true, + }, + }, + }, + -- Needed for auto-completion with method signatures and placeholders + capabilities = require('blink-cmp').get_lsp_capabilities(), + flags = { + allow_incremental_sync = true, + }, + init_options = { + -- References the bundles defined above to support Debugging and Unit Testing + bundles = bundles, + extendedClientCapabilities = jdtls.extendedClientCapabilities, + }, +} + +-- Needed for debugging +config['on_attach'] = function(client, bufnr) + jdtls.setup_dap { hotcodereplace = 'auto' } + require('jdtls.dap').setup_dap_main_class_configs() +end + +-- This starts a new client & server, or attaches to an existing client & server based on the `root_dir`. +jdtls.start_or_attach(config) diff --git a/init.lua b/init.lua index 5d7418ee..53e57e39 100644 --- a/init.lua +++ b/init.lua @@ -513,7 +513,6 @@ rtp:prepend(lazypath) -- [[ Configure and install plugins ]] require('lazy').setup({ - { import = 'kickstart.plugins' }, { import = 'kickstart.plugins.lsp' }, { import = 'custom.plugins' }, diff --git a/lazy-lock.json b/lazy-lock.json index 3e6b9322..769805ec 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,29 +1,29 @@ { - "LazyVim": { "branch": "main", "commit": "b9d38f692015fecaa72d55282b74a3d601e4c9fa" }, "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" }, "blink.cmp": { "branch": "main", "commit": "327fff91fe6af358e990be7be1ec8b78037d2138" }, - "conform.nvim": { "branch": "master", "commit": "c64cc754ace603e185ab30113aaef174187eacf8" }, + "conform.nvim": { "branch": "master", "commit": "fbcb4fa7f34bfea9be702ffff481a8e336ebf6ed" }, "fidget.nvim": { "branch": "main", "commit": "3f5475949679953af6d78654db29b944fa826e6a" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "1ee5c1fd068c81f9dd06483e639c2aa4587dc197" }, "guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" }, + "harpoon": { "branch": "master", "commit": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, - "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "lazydev.nvim": { "branch": "main", "commit": "258d2a5ef4a3e3d6d9ba9da72c9725c53e9afcbd" }, + "lazy.nvim": { "branch": "main", "commit": "1ea3c4085785f460fb0e46d2fe1ee895f5f9e7c1" }, + "lazydev.nvim": { "branch": "main", "commit": "e28ce52fc7ff79fcb76f0e79ee6fb6182fca90b9" }, "lazygit.nvim": { "branch": "main", "commit": "2305deed25bc61b866d5d39189e9105a45cf1cfb" }, - "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "155eac5d8609a2f110041f8ac3491664cc126354" }, - "mason-nvim-dap.nvim": { "branch": "main", "commit": "86389a3dd687cfaa647b6f44731e492970034baa" }, + "lualine.nvim": { "branch": "master", "commit": "3946f0122255bc377d14a59b27b609fb3ab25768" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "2304ff65ecc8cb2afc2484de3e2ed9a407edf0b9" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "c971971f881d1be90252d281f384054d9d53e745" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" }, - "mason.nvim": { "branch": "main", "commit": "a83eabdc8c49c0c93bf5bb162fa3b57404a9d095" }, - "matteblack.nvim": { "branch": "main", "commit": "3bfd406f3b2e41eb3458fe735e06447c08b67d03" }, - "mini.nvim": { "branch": "main", "commit": "126ce3328c78399dcff58272f6f540a373b62a75" }, - "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, - "nvim-dap": { "branch": "master", "commit": "7367cec8e8f7a0b1e4566af9a7ef5959d11206a7" }, + "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, + "mini.nvim": { "branch": "main", "commit": "8a7cf7eee8d89bd1b83f6d72f7f3b5598e7ae2cb" }, + "nvim-autopairs": { "branch": "master", "commit": "7a2c97cccd60abc559344042fefb1d5a85b3e33b" }, + "nvim-dap": { "branch": "master", "commit": "6782b097af2417a4c3e33849b0a26ae2188bd7ea" }, "nvim-dap-go": { "branch": "main", "commit": "b4421153ead5d726603b02743ea40cf26a51ed5f" }, "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, - "nvim-lint": { "branch": "master", "commit": "335a6044be16d7701001059cba9baa36fbeef422" }, - "nvim-lspconfig": { "branch": "master", "commit": "db8fef885009fdec0daeff3e5dda92e1f539611e" }, + "nvim-jdtls": { "branch": "master", "commit": "380ac148f989e1291aac002dc959ecc68c5243d0" }, + "nvim-lint": { "branch": "master", "commit": "9da1fb942dd0668d5182f9c8dee801b9c190e2bb" }, + "nvim-lspconfig": { "branch": "master", "commit": "ac98db2f9f06a56498ec890a96928774eae412c3" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, @@ -32,16 +32,17 @@ "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" }, "nvim-web-devicons": { "branch": "master", "commit": "b8221e42cf7287c4dcde81f232f58d7b947c210d" }, "oil-git-status.nvim": { "branch": "main", "commit": "4b5cf53842c17a09420919e655a6a559da3112d7" }, - "oil.nvim": { "branch": "master", "commit": "919e155fdf38e9148cdb5304faaaf53c20d703ea" }, - "oklch-color-picker.nvim": { "branch": "master", "commit": "ae318113cd7d0e4988b6b059327c2778911f1187" }, + "oil.nvim": { "branch": "master", "commit": "71948729cda5fc1b761d6ae60ff774b5525f1d50" }, + "oklch-color-picker.nvim": { "branch": "master", "commit": "da958405624e31336cc76ca0075f4a255e6c448a" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "supermaven-nvim": { "branch": "main", "commit": "07d20fce48a5629686aefb0a7cd4b25e33947d50" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, - "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "29315861711f11daf75e1cf0953ab92ec1a3e69f" }, - "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, - "trouble.nvim": { "branch": "main", "commit": "f176232e7759c4f8abd923c21e3e5a5c76cd6837" }, + "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "1cb11cc658ee24a9826e3b909ca0b0f5e60597c7" }, + "todo-comments.nvim": { "branch": "main", "commit": "19d461ddd543e938eb22505fb03fa878800270b6" }, + "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }, + "trouble.nvim": { "branch": "main", "commit": "c098362fe603d3922095e7db595961e020bdf2d0" }, "vim-tmux-navigator": { "branch": "master", "commit": "c45243dc1f32ac6bcf6068e5300f3b2b237e576a" }, - "which-key.nvim": { "branch": "main", "commit": "904308e6885bbb7b60714c80ab3daf0c071c1492" } + "which-key.nvim": { "branch": "main", "commit": "b4177e3eaf15fe5eb8357ebac2286d488be1ed00" } } diff --git a/lua/custom/after/transparency.lua b/lua/custom/after/transparency.lua index d0090f07..59845a34 100644 --- a/lua/custom/after/transparency.lua +++ b/lua/custom/after/transparency.lua @@ -1,45 +1,45 @@ -- transparent background -vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) -vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) -vim.api.nvim_set_hl(0, "FloatBorder", { bg = "none" }) -vim.api.nvim_set_hl(0, "Pmenu", { bg = "none" }) -vim.api.nvim_set_hl(0, "Terminal", { bg = "none" }) -vim.api.nvim_set_hl(0, "EndOfBuffer", { bg = "none" }) -vim.api.nvim_set_hl(0, "FoldColumn", { bg = "none" }) -vim.api.nvim_set_hl(0, "Folded", { bg = "none" }) -vim.api.nvim_set_hl(0, "SignColumn", { bg = "none" }) -vim.api.nvim_set_hl(0, "NormalNC", { bg = "none" }) -vim.api.nvim_set_hl(0, "WhichKeyFloat", { bg = "none" }) -vim.api.nvim_set_hl(0, "TelescopeBorder", { bg = "none" }) -vim.api.nvim_set_hl(0, "TelescopeNormal", { bg = "none" }) -vim.api.nvim_set_hl(0, "TelescopePromptBorder", { bg = "none" }) -vim.api.nvim_set_hl(0, "TelescopePromptTitle", { bg = "none" }) +vim.api.nvim_set_hl(0, 'Normal', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NormalFloat', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'FloatBorder', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'Pmenu', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'Terminal', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'EndOfBuffer', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'FoldColumn', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'Folded', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'SignColumn', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NormalNC', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'WhichKeyFloat', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'TelescopeBorder', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'TelescopeNormal', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'TelescopePromptBorder', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'TelescopePromptTitle', { bg = 'none' }) -- transparent background for neotree -vim.api.nvim_set_hl(0, "NeoTreeNormal", { bg = "none" }) -vim.api.nvim_set_hl(0, "NeoTreeNormalNC", { bg = "none" }) -vim.api.nvim_set_hl(0, "NeoTreeVertSplit", { bg = "none" }) -vim.api.nvim_set_hl(0, "NeoTreeWinSeparator", { bg = "none" }) -vim.api.nvim_set_hl(0, "NeoTreeEndOfBuffer", { bg = "none" }) +vim.api.nvim_set_hl(0, 'NeoTreeNormal', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NeoTreeNormalNC', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NeoTreeVertSplit', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NeoTreeWinSeparator', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NeoTreeEndOfBuffer', { bg = 'none' }) -- transparent background for nvim-tree -vim.api.nvim_set_hl(0, "NvimTreeNormal", { bg = "none" }) -vim.api.nvim_set_hl(0, "NvimTreeVertSplit", { bg = "none" }) -vim.api.nvim_set_hl(0, "NvimTreeEndOfBuffer", { bg = "none" }) +vim.api.nvim_set_hl(0, 'NvimTreeNormal', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NvimTreeVertSplit', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NvimTreeEndOfBuffer', { bg = 'none' }) -- transparent notify background -vim.api.nvim_set_hl(0, "NotifyINFOBody", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyERRORBody", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyWARNBody", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyTRACEBody", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyDEBUGBody", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyINFOTitle", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyERRORTitle", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyWARNTitle", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyTRACETitle", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyDEBUGTitle", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyINFOBorder", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyERRORBorder", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyWARNBorder", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyTRACEBorder", { bg = "none" }) -vim.api.nvim_set_hl(0, "NotifyDEBUGBorder", { bg = "none" }) +vim.api.nvim_set_hl(0, 'NotifyINFOBody', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyERRORBody', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyWARNBody', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyTRACEBody', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyDEBUGBody', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyINFOTitle', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyERRORTitle', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyWARNTitle', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyTRACETitle', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyDEBUGTitle', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyINFOBorder', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyERRORBorder', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyWARNBorder', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyTRACEBorder', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NotifyDEBUGBorder', { bg = 'none' }) diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000..fc8fc371 --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,76 @@ +return { + 'ThePrimeagen/harpoon', + cmd = 'Harpoon', + keys = { + { + 'hh', + 'lua require("harpoon.ui").toggle_quick_menu()', + desc = 'Toggle Harpoon Quick Menu', + }, + { + 'ha', + 'lua require("harpoon.mark").add_file()', + desc = 'Mark Current File', + }, + { + 'hr', + 'lua require("harpoon.mark").clear_file()', + desc = 'Remove Current File', + }, + { + 'hn', + 'lua require("harpoon.ui").nav_next()', + desc = 'Next Harpoon', + }, + { + 'hp', + 'lua require("harpoon.ui").nav_prev()', + desc = 'Previous Harpoon', + }, + { + 'h&', + 'lua require("harpoon.ui").nav_file(1)', + desc = 'Go to 1st Mark', + }, + { + 'hé', + 'lua require("harpoon.ui").nav_file(2)', + desc = 'Go to 2nd Mark', + }, + { + 'h"', + 'lua require("harpoon.ui").nav_file(3)', + desc = 'Go to 3rd Mark', + }, + { + "h'", + 'lua require("harpoon.ui").nav_file(4)', + desc = 'Go to 4th Mark', + }, + { + 'h(', + 'lua require("harpoon.ui").nav_file(5)', + desc = 'Go to 5th Mark', + }, + { + 'h§', + 'lua require("harpoon.ui").nav_file(6)', + desc = 'Go to 6th Mark', + }, + { + 'hè', + 'lua require("harpoon.ui").nav_file(7)', + desc = 'Go to 7th Mark', + }, + { + 'h!', + 'lua require("harpoon.ui").nav_file(8)', + desc = 'Go to 8th Mark', + }, + { + 'hç', + 'lua require("harpoon.ui").nav_file(9)', + desc = 'Go to 9th Mark', + }, + }, +} diff --git a/lua/custom/plugins/noice.lua b/lua/custom/plugins/noice.lua deleted file mode 100644 index 8dcdbc65..00000000 --- a/lua/custom/plugins/noice.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - -- lazy.nvim - { - 'rcarriga/nvim-notify', - event = 'VeryLazy', - opts = {}, - }, -} diff --git a/lua/custom/plugins/notify.lua b/lua/custom/plugins/notify.lua new file mode 100644 index 00000000..56f50d95 --- /dev/null +++ b/lua/custom/plugins/notify.lua @@ -0,0 +1,22 @@ +return { + 'rcarriga/nvim-notify', + event = 'VeryLazy', + config = function() + local notify = require 'notify' + notify.setup { + merge_duplicates = true, + background_colour = '#000000', + render = 'default', + timeout = 5000, + stages = 'fade', + icons = { + ERROR = '', + WARN = '', + INFO = '', + DEBUG = '', + TRACE = '✎', + }, + } + vim.notify = notify + end, +} diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua index bdbedd8d..2fdb760b 100644 --- a/lua/custom/plugins/oil.lua +++ b/lua/custom/plugins/oil.lua @@ -58,7 +58,6 @@ return { vim.api.nvim_create_autocmd('User', { pattern = 'OilEnter', callback = vim.schedule_wrap(function(args) - local oil = require 'oil' if vim.api.nvim_get_current_buf() == args.data.buf and oil.get_cursor_entry() then oil.open_preview() end diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua index cc2c2305..018799e5 100644 --- a/lua/custom/plugins/trouble.lua +++ b/lua/custom/plugins/trouble.lua @@ -19,6 +19,16 @@ return { 'Trouble quickfix toggle', desc = 'Toggle Quickfix List', }, + { + 'qn', + 'cnext', + desc = 'Diagnostic Next', + }, + { + 'qp', + 'cprevious', + desc = 'Diagnostic Previous', + }, { 'ql', 'Trouble loclist toggle', diff --git a/lua/custom/snippets/elexir.lua b/lua/custom/snippets/elexir.lua new file mode 100644 index 00000000..a9781802 --- /dev/null +++ b/lua/custom/snippets/elexir.lua @@ -0,0 +1,11 @@ +-- Elixir snippets + +local ls = require 'luasnip' +local s = ls.snippet +local i = ls.insert_node + +local fmt = require('luasnip.extras.fmt').fmt + +ls.add_snippets('elixir', { + s('el', fmt('<%= {} %>{}', { i(1), i(0) })), +}) diff --git a/lua/custom/snippets/kotlin.lua b/lua/custom/snippets/kotlin.lua new file mode 100644 index 00000000..e47db414 --- /dev/null +++ b/lua/custom/snippets/kotlin.lua @@ -0,0 +1,33 @@ +-- Kotlin snippets + +local ls = require 'luasnip' +local s = ls.snippet +local i = ls.insert_node +local t = ls.text_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node + +local fmt = require('luasnip.extras.fmt').fmt + +ls.add_snippets('kotlin', { + s( + 'comp', + fmt( + [[ + @Composable + fun []([]) { + [] + } + ]], + { + i(1, 'name'), + i(2, 'params'), + i(3, 'body'), + }, + { + delimiters = '[]', + } + ) + ), +}) diff --git a/lua/kickstart/plugins/auto-completion.lua b/lua/kickstart/plugins/auto-completion.lua index f51dbffc..fd34bf36 100644 --- a/lua/kickstart/plugins/auto-completion.lua +++ b/lua/kickstart/plugins/auto-completion.lua @@ -4,29 +4,7 @@ return { event = 'VimEnter', version = '1.*', dependencies = { - -- Snippet Engine - { - 'L3MON4D3/LuaSnip', - version = '2.*', - build = (function() - -- Build Step is needed for regex support in snippets. - -- This step is not supported in many windows environments. - -- Remove the below condition to re-enable on windows. - 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, - }, - }, - opts = {}, - }, + 'L3MON4D3/LuaSnip', 'folke/lazydev.nvim', }, --- @module 'blink.cmp' @@ -83,7 +61,7 @@ return { }, sources = { - default = { 'lsp', 'path', 'snippets', 'lazydev' }, + default = { 'lsp', 'path', 'snippets', 'lazydev', 'buffer' }, providers = { lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, }, diff --git a/lua/kickstart/plugins/format.lua b/lua/kickstart/plugins/format.lua index 8487dadf..804b31e9 100644 --- a/lua/kickstart/plugins/format.lua +++ b/lua/kickstart/plugins/format.lua @@ -19,8 +19,14 @@ return { -- Autoformat -- have a well standardized coding style. You can add additional -- languages here or re-enable it for the disabled ones. local disable_filetypes = { c = true, cpp = true } + local slow_filetypes = { kotlin = true } if disable_filetypes[vim.bo[bufnr].filetype] then return nil + elseif slow_filetypes[vim.bo[bufnr].filetype] then + return { + timeout_ms = 2500, + lsp_format = 'fallback', + } else return { timeout_ms = 500, @@ -54,6 +60,8 @@ return { -- Autoformat sh = { 'shellcheck' }, go = { 'gofmt', 'goimports', 'goimports_reviser' }, xml = { 'xmllint' }, + c = { 'clang-format' }, + python = { 'black' }, }, }, } diff --git a/lua/kickstart/plugins/lsp/jdtls.lua b/lua/kickstart/plugins/lsp/jdtls.lua new file mode 100644 index 00000000..45bdf3d2 --- /dev/null +++ b/lua/kickstart/plugins/lsp/jdtls.lua @@ -0,0 +1,5 @@ +-- Java LSP +return { + 'mfussenegger/nvim-jdtls', + ft = { 'java', 'kotlin', 'kt' }, +} diff --git a/lua/kickstart/plugins/lsp/main-lsp.lua b/lua/kickstart/plugins/lsp/main-lsp.lua index 66e1ca2e..cd1b9796 100644 --- a/lua/kickstart/plugins/lsp/main-lsp.lua +++ b/lua/kickstart/plugins/lsp/main-lsp.lua @@ -16,83 +16,23 @@ return { 'saghen/blink.cmp', }, config = function() - -- Brief aside: **What is LSP?** - -- - -- LSP is an initialism you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), callback = function(event) - -- NOTE: Remember that Lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. local map = function(keys, func, desc, mode) mode = mode or 'n' vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. map('grn', vim.lsp.buf.rename, '[R]e[n]ame') - - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. map('gca', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) - - -- Find references for the word under your cursor. - map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. - map('gi', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - - -- Jump to the definition of the word under your cursor. - -- This is where a variable was first declared, or where a function is defined, etc. - -- To jump back, press . - map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - - -- WARN: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header. map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. + map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + map('gi', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') map('gt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') - - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') - - -- Fuzzy find all the symbols in your current workspace. - -- Similar to document symbols, except searches over your entire project. map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) @@ -137,10 +77,6 @@ return { }) end - -- The following code creates a keymap to toggle inlay hints in your - -- code, if the language server you are using supports them - -- - -- This may be unwanted, since they displace some of your code if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then map('th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) @@ -185,17 +121,8 @@ return { local capabilities = require('blink.cmp').get_lsp_capabilities() local util = require 'lspconfig/util' - -- Enable the following language servers - -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. - -- - -- Add any additional override configuration in the following tables. Available keys are: - -- - cmd (table): Override the default command used to start the server - -- - filetypes (table): Override the default list of associated filetypes for the server - -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. - -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { - -- clangd = {}, + clangd = {}, gopls = { capabilities = capabilities, cmd = { 'gopls' }, @@ -211,7 +138,7 @@ return { }, }, }, - -- pyright = {}, + pyright = {}, rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -224,7 +151,10 @@ return { }, vue_ls = {}, eslint = {}, - -- + yamlls = {}, + html = { + filetypes = { 'html', 'htmldjango', 'htmldjango-template', 'htmljinja', 'htmlmin' }, + }, lua_ls = { -- cmd = { ... }, @@ -236,28 +166,42 @@ return { callSnippet = 'Replace', }, -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings + diagnostics = { + globals = { 'vim' }, + }, -- diagnostics = { disable = { 'missing-fields' } }, }, }, }, + kotlin_language_server = { + settings = { + kotlin = { + enabled = true, + debug = true, + languageVersion = '2.0', + jvmTarget = '21', + includeNonDeclarations = true, + noStdlib = false, + noReflect = false, + incremental = true, + buildServerMode = false, + compilerOptions = { + jvmTarget = '21', + apiVersion = '1.8', + languageVersion = '2.0', + }, + }, + }, + }, } -- Ensure the servers and tools above are installed - -- - -- To check the current status of installed tools and/or manually install - -- other tools, you can run - -- :Mason - -- - -- You can press `g?` for help in this menu. - -- - -- `mason` had to be setup earlier: to configure its options see the - -- `dependencies` table for `nvim-lspconfig` above. - -- - -- You can add other tools here that you want Mason to install - -- for you, so that they are available from within Neovim. local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'jdtls', + 'java-debug-adapter', + 'java-test', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -266,14 +210,29 @@ return { automatic_installation = false, handlers = { function(server_name) + -- Don't call setup for jdtls, it's already setup in the jdtls.lua file local server = servers[server_name] or {} -- This handles overriding only values explicitly passed -- by the server configuration above. Useful when disabling -- certain features of an LSP (for example, turning off formatting for ts_ls) server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) + vim.lsp.config(server_name, server) end, }, } + + -- Non Mason LSP servers + -- vim.lsp.enable 'kotlin_lsp' + -- vim.lsp.config('kotlin_lsp', { + -- capabilities = capabilities, + -- }) + + -- Globally configure all LSP floating preview popups (like hover, signature help, etc) + local open_floating_preview = vim.lsp.util.open_floating_preview + function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) + opts = opts or {} + opts.border = opts.border or 'rounded' -- Set border to rounded + return open_floating_preview(contents, syntax, opts, ...) + end end, } diff --git a/lua/kickstart/plugins/lualine.lua b/lua/kickstart/plugins/lualine.lua index 9446f8e7..fb495723 100644 --- a/lua/kickstart/plugins/lualine.lua +++ b/lua/kickstart/plugins/lualine.lua @@ -4,7 +4,7 @@ return { config = function() require('lualine').setup { options = { - theme = 'tokyonight', + theme = vim.g.colors_name or 'auto', component_separators = '', section_separators = { left = '', right = '' }, disabled_filetypes = { diff --git a/lua/kickstart/plugins/mini.lua b/lua/kickstart/plugins/mini.lua index 49db3a86..69a98f44 100644 --- a/lua/kickstart/plugins/mini.lua +++ b/lua/kickstart/plugins/mini.lua @@ -2,24 +2,9 @@ return { 'echasnovski/mini.nvim', config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [Q]uote - -- - ci' - [C]hange [I]nside [']quote require('mini.ai').setup { n_lines = 500 } - - -- Add/delete/replace surroundings (brackets, quotes, etc.) - -- - -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren - -- - sd' - [S]urround [D]elete [']quotes - -- - sr)' - [S]urround [R]eplace [)] ['] require('mini.surround').setup() - - -- Simple and easy statusline. - -- You could remove this setup call if you don't like it, - -- and try some other statusline plugin + require('mini.move').setup() local statusline = require 'mini.statusline' -- set use_icons to true if you have a Nerd Font statusline.setup { use_icons = vim.g.have_nerd_font } @@ -31,8 +16,5 @@ return { statusline.section_location = function() return '%2l:%-2v' end - - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim end, } diff --git a/lua/kickstart/plugins/snippets.lua b/lua/kickstart/plugins/snippets.lua new file mode 100644 index 00000000..236bca1e --- /dev/null +++ b/lua/kickstart/plugins/snippets.lua @@ -0,0 +1,51 @@ +return { + 'L3MON4D3/LuaSnip', + event = 'VimEnter', + version = '2.*', + build = (function() + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. + 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, + }, + }, + config = function() + local ls = require 'luasnip' + ls.config.set_config { + history = false, + updateevents = 'TextChanged,TextChangedI', + } + + for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/custom/snippets/*lua', true)) do + loadfile(ft_path)() + end + + vim.keymap.set({ 'i', 's' }, '', function() + if ls.expand_or_jumpable() then + ls.expand_or_jump() + end + end, { silent = true }) + + vim.keymap.set({ 'i', 's' }, '', function() + if ls.jumpable(-1) then + ls.jump(-1) + end + end, { silent = true }) + + vim.keymap.set({ 'i', 's' }, '', function() + if ls.jumpable(1) then + ls.jump(1) + end + end, { silent = true }) + end, +} diff --git a/lua/kickstart/plugins/treesitter.lua b/lua/kickstart/plugins/treesitter.lua index 72549744..732c1bc9 100644 --- a/lua/kickstart/plugins/treesitter.lua +++ b/lua/kickstart/plugins/treesitter.lua @@ -26,11 +26,23 @@ return { -- Highlight, edit, and navigate code 'go', 'typescript', 'javascript', + 'kotlin', + 'yaml', + 'html', + 'json', + 'jsonc', + 'markdown', + 'markdown_inline', + 'python', + 'rust', + 'toml', + 'yaml', }, -- Autoinstall languages that are not installed auto_install = true, highlight = { enable = true, + disable = { 'python' }, -- list of language that will be disabled -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. -- If you are experiencing weird indenting issues, add the language to -- the list of additional_vim_regex_highlighting and disabled languages for indent.