diff options
| author | Kyren223 <contact@kyren.codes> | 2026-06-22 01:30:43 +0300 |
|---|---|---|
| committer | Kyren223 <contact@kyren.codes> | 2026-06-22 01:30:43 +0300 |
| commit | 604addae2145f5823a2830927187489f5a79b92d (patch) | |
| tree | 2664321e35347605a5751fef0c6a2262e9f4664c /.config/nvim/lua/plugins | |
| parent | 48b2a7d4a56784f3695a92c274be9ae3a034ee4b (diff) | |
Add java and kotlin config
Diffstat (limited to '.config/nvim/lua/plugins')
| -rw-r--r-- | .config/nvim/lua/plugins/nvim-jdtls.lua | 73 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/nvim-treesitter.lua | 1 |
2 files changed, 60 insertions, 14 deletions
diff --git a/.config/nvim/lua/plugins/nvim-jdtls.lua b/.config/nvim/lua/plugins/nvim-jdtls.lua index 21a5fc4..c1f4962 100644 --- a/.config/nvim/lua/plugins/nvim-jdtls.lua +++ b/.config/nvim/lua/plugins/nvim-jdtls.lua @@ -1,19 +1,64 @@ return { 'mfussenegger/nvim-jdtls', ft = { 'java' }, - opts = { - cmd = { 'jdtls' }, - root_dir = vim.fs.dirname(vim.fs.find({ - '.git', - 'build.gradle', - 'build.gradle.kts', - 'build.xml', - 'pom.xml', - 'settings.gradle', - 'settings.gradle.kts', - }, { upward = true })[1]), - }, - config = function(_, opts) - require('jdtls').start_or_attach(opts) + dependencies = { 'Saghen/blink.cmp' }, + config = function() + local setup_jdtls = function() + local current_buf = vim.api.nvim_buf_get_name(0) + local root_file = vim.fs.find({ + '.git', + 'build.gradle', + 'build.gradle.kts', + 'build.xml', + 'pom.xml', + 'settings.gradle', + 'settings.gradle.kts', + }, { upward = true, path = current_buf })[1] + + local root_dir = root_file and vim.fs.dirname(root_file) or vim.fn.getcwd() + local project_name = vim.fn.fnamemodify(root_dir, ':p:h:t') + local workspace_dir = vim.fn.expand('~/.cache/jdtls-workspace/') .. project_name + + -- Safely mix standard blink capabilities with internal jdtls mappings + local lsp_capabilities = require('blink.cmp').get_lsp_capabilities() + + local opts = { + cmd = { 'jdtls', '-data', workspace_dir }, + root_dir = root_dir, + capabilities = lsp_capabilities, + + -- Extended capabilities must live here, NOT in the root capabilities key + init_options = { + extendedClientCapabilities = require('jdtls').extendedClientCapabilities, + }, + + settings = { + java = { + signatureHelp = { enabled = true }, + compile = { + nullAnalysis = { + mode = 'enabled', + nullable = { 'org.jspecify.annotations.Nullable' }, + nonnull = { 'org.jspecify.annotations.NonNull' }, + nonnullbydefault = { 'org.jspecify.annotations.NullMarked' }, + }, + }, + format = { enabled = true }, + errors = { + incompleteClasspath = 'warning', + }, + }, + }, + } + + require('jdtls').start_or_attach(opts) + end + + setup_jdtls() + + vim.api.nvim_create_autocmd('FileType', { + pattern = 'java', + callback = setup_jdtls, + }) end, } diff --git a/.config/nvim/lua/plugins/nvim-treesitter.lua b/.config/nvim/lua/plugins/nvim-treesitter.lua index 4301939..e79070d 100644 --- a/.config/nvim/lua/plugins/nvim-treesitter.lua +++ b/.config/nvim/lua/plugins/nvim-treesitter.lua @@ -46,6 +46,7 @@ return { 'jsdoc', 'json', 'jsonc', + 'kotlin', 'latex', 'linkerscript', 'lua', |
