Skip to content
This repository was archived by the owner on Mar 3, 2022. It is now read-only.
This repository was archived by the owner on Mar 3, 2022. It is now read-only.

Requesting help regarding a java filetype autocmd #1

@ghost

Description

local _, jdtls = lsp_installer.get_server("jdtls")
-- selene: allow(unused_variable)
---@diagnostic disable-next-line: unused-local
--local config = {
--      cmd = jdtls:get_default_options().cmd,
--      root_dir = require("jdtls.setup").find_root({ ".git", "mvnw", "gradlew" }),
--      capabilities = default_capabilities,
--      on_attach = default_on_attach,
--  }
-- cmd([[autocmd FileType java lua require('jdtls').start_or_attach(config)]])
require("autocmd-lua").augroup({
	group = "nvim-jdtls",
	autocmds = {
		{
			"FileType",
			"java",
			function()
				require("jdtls").start_or_attach({
					cmd = jdtls:get_default_options().cmd,
					root_dir = require("jdtls.setup").find_root({ ".git", "mvnw", "gradlew" }),
					capabilities = default_capabilities,
					on_attach = default_on_attach,
				})
			end,
		},
	},
})

Hello. Since config doesn't get valued inside cmd([[autocmd FileType java lua require('jdtls').start_or_attach(config)]]) I'm trying to find an alternative. While searching I came upon this repository which I think could solve my problem ( starting nvim-jdtls only for java files ). Could you please point out what exactly I'm doing wrong ?

Here is also the whole file for reference: https://0x0.st/orHv.lua

EDIT: and also the init.vim which sources this lua: https://0x0.st/or8S.vim

I was eventually able to solve this using a simple if vim.bo.filetype == "java" then, I'm still curious about this but please feel free to close it if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions