summaryrefslogtreecommitdiffstats
path: root/after
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2025-05-18 13:03:31 -0500
committerSquibid <me@zacharyscheiman.com>2025-05-18 13:03:31 -0500
commit450750835a01f64377434d6be0c7869ca59b7574 (patch)
treee957a9612b3a3425200856be6656fff5cff9543a /after
parent77130d61af1e88855e273d042714f90323e04edf (diff)
downloadnvim-450750835a01f64377434d6be0c7869ca59b7574.tar.gz
nvim-450750835a01f64377434d6be0c7869ca59b7574.tar.bz2
nvim-450750835a01f64377434d6be0c7869ca59b7574.zip
need I say what type of commit this is?
*kitchen sink*
Diffstat (limited to 'after')
-rw-r--r--after/ftplugin/java.lua48
-rw-r--r--after/plugin/colorscheme.lua6
2 files changed, 37 insertions, 17 deletions
diff --git a/after/ftplugin/java.lua b/after/ftplugin/java.lua
index 9e11fa6..ee47369 100644
--- a/after/ftplugin/java.lua
+++ b/after/ftplugin/java.lua
@@ -1,7 +1,15 @@
local misc = require("core.misc")
local map, auto = misc.map, misc.auto
-local jdtls = require("jdtls")
+local ok, jdtls = pcall(require, "jdtls")
+if not ok then
+ vim.notify("jdtls not loaded, can't setup jdtls lsp or dap",
+ vim.log.levels.INFO, {})
+ return
+end
+
+-- HACK: I don't like using path concatination there *should* be a way to get
+-- the path from mason
local jdtls_install = vim.fs.joinpath(vim.fn.stdpath('data'),
"/mason/packages/jdtls")
local java_dap_install = vim.fs.joinpath(vim.fn.stdpath('data'),
@@ -24,7 +32,7 @@ local config = {
"-Dlog.level=ALL",
"-Dlog.protocol=true",
"-Dosgi.bundles.defaultStartLevel=4",
- "-Xmx1G",
+ "-Xmx1G"
},
root_dir = vim.fs.dirname(vim.fs.find({
@@ -49,6 +57,7 @@ local config = {
map("x", "crc", function() jdtls.extract_constant(true) end, opts)
map("x", "crm", function() jdtls.extract_method(true) end, opts)
+ -- do some refreshes often because I don't trust jdtls
pcall(vim.lsp.codelens.refresh)
auto("BufWritePost", {
buffer = bufnr,
@@ -59,7 +68,14 @@ local config = {
})
-- setup nvim-dap
- require("dap").adapters.java = nil -- remove any old java adapters
+ local ok, dap = pcall(require, "dap")
+ if not ok then
+ vim.notify("dap not loaded can't setup dap for jdtls",
+ vim.log.levels.INFO, {})
+ return
+ end
+
+ dap.adapters.java = nil -- remove any old java adapters
jdtls.setup_dap({ hotcodereplace = "auto" })
require("jdtls.dap").setup_dap_main_class_configs()
end,
@@ -79,6 +95,8 @@ local config = {
}
}
+-- HACK: same hack as before
+
-- generate the path to the java file(s)
---@type string?
local cache_path = vim.fs.joinpath(vim.fn.stdpath("cache"),
@@ -95,20 +113,18 @@ end
--- build a cache of the JavaVersion code
local function build_cache()
-- check if we have javac
- vim.system({ "javac" }, {}, function(out)
- if out.code == 127 then
- cache_path = nil
- return
- end
+ if vim.fn.executable("javac") ~= 1 then
+ cache_path = nil
+ return
+ end
- -- compile our code
- vim.system({ "javac", src_path, "-d", vim.fn.stdpath("cache"), }, {},
- function(out)
- if out.code ~= 0 then
- cache_path = nil
- end
- end)
- end)
+ -- compile our code
+ vim.system({ "javac", src_path, "-d", vim.fn.stdpath("cache"), }, {},
+ function(out)
+ if out.code ~= 0 then
+ cache_path = nil
+ end
+ end)
end
-- check if we have a compiled version of JavaVersion
diff --git a/after/plugin/colorscheme.lua b/after/plugin/colorscheme.lua
index b5fbd81..039f926 100644
--- a/after/plugin/colorscheme.lua
+++ b/after/plugin/colorscheme.lua
@@ -1 +1,5 @@
-vim.cmd("colorscheme mellow")
+if vim.fn.has("termguicolors") and not os.getenv("TERM") ~= "linux" then
+ vim.cmd("colorscheme mellow")
+else
+ vim.cmd("colorscheme default")
+end