autocmd-lua icon indicating copy to clipboard operation
autocmd-lua copied to clipboard

Requesting help regarding a java filetype autocmd

Open punowo opened this issue 3 years ago • 0 comments

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.

punowo avatar Dec 24 '21 07:12 punowo