Skip to content

Commit 2d9f19f

Browse files
committed
first commit
0 parents  commit 2d9f19f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+7463
-0
lines changed

.stylua.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
column_width = 120
2+
line_endings = "Unix"
3+
indent_type = "Spaces"
4+
indent_width = 2
5+
quote_style = "AutoPreferDouble"
6+
call_parentheses = "Always"
7+
collapse_simple_statement = "Never"
8+
9+
[sort_requires]
10+
enabled = false

ftplugin/c.lua

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vim.opt.shiftwidth = 4
2+
vim.opt.tabstop = 4

ftplugin/java.lua

+201
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
local status, jdtls = pcall(require, "jdtls")
2+
if not status then
3+
return
4+
end
5+
6+
-- Determine OS
7+
local home = os.getenv("HOME")
8+
if vim.fn.has("mac") == 1 then
9+
WORKSPACE_PATH = home .. "/workspace/"
10+
CONFIG = "mac"
11+
elseif vim.fn.has("unix") == 1 then
12+
WORKSPACE_PATH = home .. "/workspace/"
13+
CONFIG = "linux"
14+
else
15+
print("Unsupported system")
16+
end
17+
18+
-- Find root of project
19+
local root_markers = { ".git", "mvnw", "gradlew", "pom.xml", "build.gradle" }
20+
local root_dir = require("jdtls.setup").find_root(root_markers)
21+
if root_dir == "" then
22+
return
23+
end
24+
25+
local extendedClientCapabilities = jdtls.extendedClientCapabilities
26+
extendedClientCapabilities.resolveAdditionalTextEditsSupport = true
27+
28+
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
29+
30+
local workspace_dir = WORKSPACE_PATH .. project_name
31+
32+
JAVA_DAP_ACTIVE = true
33+
34+
local bundles = {
35+
vim.fn.glob(
36+
home .. "/.config/nvim/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar"
37+
),
38+
}
39+
40+
vim.list_extend(bundles, vim.split(vim.fn.glob(home .. "/.config/nvim/vscode-java-test/server/*.jar"), "\n"))
41+
42+
-- See `:help vim.lsp.start_client` for an overview of the supported `config` options.
43+
local config = {
44+
-- The command that starts the language server
45+
-- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
46+
cmd = {
47+
48+
-- 💀
49+
"java", -- or '/path/to/java11_or_newer/bin/java'
50+
-- depends on if `java` is in your $PATH env variable and if it points to the right version.
51+
52+
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
53+
"-Dosgi.bundles.defaultStartLevel=4",
54+
"-Declipse.product=org.eclipse.jdt.ls.core.product",
55+
"-Dlog.protocol=true",
56+
"-Dlog.level=ALL",
57+
"-javaagent:" .. home .. "/.local/share/nvim/lsp_servers/jdtls/lombok.jar",
58+
"-Xms1g",
59+
"--add-modules=ALL-SYSTEM",
60+
"--add-opens",
61+
"java.base/java.util=ALL-UNNAMED",
62+
"--add-opens",
63+
"java.base/java.lang=ALL-UNNAMED",
64+
65+
-- 💀
66+
"-jar",
67+
vim.fn.glob(home .. "/.local/share/nvim/lsp_servers/jdtls/plugins/org.eclipse.equinox.launcher_*.jar"),
68+
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
69+
-- Must point to the Change this to
70+
-- eclipse.jdt.ls installation the actual version
71+
72+
-- 💀
73+
"-configuration",
74+
home .. "/.local/share/nvim/lsp_servers/jdtls/config_" .. CONFIG,
75+
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
76+
-- Must point to the Change to one of `linux`, `win` or `mac`
77+
-- eclipse.jdt.ls installation Depending on your system.
78+
79+
-- 💀
80+
-- See `data directory configuration` section in the README
81+
"-data",
82+
workspace_dir,
83+
},
84+
85+
on_attach = require("akash.lsp.attach").on_attach,
86+
capabilities = require("akash.lsp.attach").capabilities,
87+
88+
-- 💀
89+
-- This is the default if not provided, you can remove it. Or adjust as needed.
90+
-- One dedicated LSP server & client will be started per unique root_dir
91+
root_dir = root_dir,
92+
93+
-- Here you can configure eclipse.jdt.ls specific settings
94+
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
95+
-- or https://github.com/redhat-developer/vscode-java#supported-vs-code-settings
96+
-- for a list of options
97+
settings = {
98+
java = {
99+
eclipse = {
100+
downloadSources = true,
101+
},
102+
configuration = {
103+
updateBuildConfiguration = "interactive",
104+
},
105+
maven = {
106+
downloadSources = true,
107+
},
108+
implementationsCodeLens = {
109+
enabled = true,
110+
},
111+
referencesCodeLens = {
112+
enabled = true,
113+
},
114+
references = {
115+
includeDecompiledSources = true,
116+
},
117+
-- Set this to true to use jdtls as your formatter
118+
format = {
119+
enabled = false,
120+
},
121+
},
122+
signatureHelp = { enabled = true },
123+
completion = {
124+
favoriteStaticMembers = {
125+
"org.hamcrest.MatcherAssert.assertThat",
126+
"org.hamcrest.Matchers.*",
127+
"org.hamcrest.CoreMatchers.*",
128+
"org.junit.jupiter.api.Assertions.*",
129+
"java.util.Objects.requireNonNull",
130+
"java.util.Objects.requireNonNullElse",
131+
"org.mockito.Mockito.*",
132+
},
133+
},
134+
contentProvider = { preferred = "fernflower" },
135+
extendedClientCapabilities = extendedClientCapabilities,
136+
sources = {
137+
organizeImports = {
138+
starThreshold = 9999,
139+
staticStarThreshold = 9999,
140+
},
141+
},
142+
codeGeneration = {
143+
toString = {
144+
template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}",
145+
},
146+
useBlocks = true,
147+
},
148+
},
149+
150+
flags = {
151+
allow_incremental_sync = true,
152+
},
153+
154+
-- Language server `initializationOptions`
155+
-- You need to extend the `bundles` with paths to jar files
156+
-- if you want to use additional eclipse.jdt.ls plugins.
157+
--
158+
-- See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation
159+
--
160+
-- If you don't plan on using the debugger or other eclipse.jdt.ls plugins you can remove this
161+
init_options = {
162+
-- bundles = {},
163+
bundles = bundles,
164+
},
165+
}
166+
167+
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
168+
pattern = { "*.java" },
169+
callback = function()
170+
vim.lsp.codelens.refresh()
171+
end,
172+
})
173+
174+
-- This starts a new client & server,
175+
-- or attaches to an existing client & server depending on the `root_dir`.
176+
require("jdtls").start_or_attach(config)
177+
178+
vim.cmd(
179+
"command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_compile JdtCompile lua require('jdtls').compile(<f-args>)"
180+
)
181+
vim.cmd(
182+
"command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_set_runtime JdtSetRuntime lua require('jdtls').set_runtime(<f-args>)"
183+
)
184+
vim.cmd("command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()")
185+
vim.cmd("command! -buffer JdtBytecode lua require('jdtls').javap()")
186+
187+
-- Shorten function name
188+
local keymap = vim.keymap.set
189+
-- Silent keymap option
190+
local opts = { silent = true }
191+
192+
keymap("n", "<leader>jo", "<Cmd>lua require'jdtls'.organize_imports()<CR>", opts)
193+
keymap("n", "<leader>jv", "<Cmd>lua require('jdtls').extract_variable()<CR>", opts)
194+
keymap("n", "<leader>jc", "<Cmd>lua require('jdtls').extract_constant()<CR>", opts)
195+
keymap("n", "<leader>jt", "<Cmd>lua require'jdtls'.test_nearest_method()<CR>", opts)
196+
keymap("n", "<leader>jT", "<Cmd>lua require'jdtls'.test_class()<CR>", opts)
197+
keymap("n", "<leader>ju", "<Cmd>JdtUpdateConfig<CR>", opts)
198+
199+
keymap("v", "<leader>jv", "<Esc><Cmd>lua require('jdtls').extract_variable(true)<CR>", opts)
200+
keymap("v", "<leader>jc", "<Esc><Cmd>lua require('jdtls').extract_constant(true)<CR>", opts)
201+
keymap("v", "<leader>jm", "<Esc><Cmd>lua require('jdtls').extract_method(true)<CR>", opts)

ftplugin/lua.lua

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
vim.opt.shiftwidth = 2
2+
vim.opt.tabstop = 2
3+
local fmt = string.format
4+
5+
-- Iterator that splits a string o a given delimiter
6+
local function split(str, delim)
7+
delim = delim or "%s"
8+
return string.gmatch(str, fmt("[^%s]+", delim))
9+
end
10+
11+
-- Find the proper directory separator depending
12+
-- on lua installation or OS.
13+
local function dir_separator()
14+
-- Look at package.config for directory separator string (it's the first line)
15+
if package.config then
16+
return string.match(package.config, "^[^\n]")
17+
elseif vim.fn.has("win32") == 1 then
18+
return "\\"
19+
else
20+
return "/"
21+
end
22+
end
23+
24+
-- Search for lua traditional include paths.
25+
-- This mimics how require internally works.
26+
local function include_paths(fname, ext)
27+
ext = ext or "lua"
28+
local sep = dir_separator()
29+
local paths = string.gsub(package.path, "%?", fname)
30+
for path in split(paths, "%;") do
31+
if vim.fn.filereadable(path) == 1 then
32+
return path
33+
end
34+
end
35+
end
36+
37+
-- Search for nvim lua include paths
38+
local function include_rtpaths(fname, ext)
39+
ext = ext or "lua"
40+
local sep = dir_separator()
41+
local rtpaths = vim.api.nvim_list_runtime_paths()
42+
local modfile, initfile = fmt("%s.%s", fname, ext), fmt("init.%s", ext)
43+
for _, path in ipairs(rtpaths) do
44+
-- Look on runtime path for 'lua/*.lua' files
45+
local path1 = table.concat({ path, ext, modfile }, sep)
46+
if vim.fn.filereadable(path1) == 1 then
47+
return path1
48+
end
49+
-- Look on runtime path for 'lua/*/init.lua' files
50+
local path2 = table.concat({ path, ext, fname, initfile }, sep)
51+
if vim.fn.filereadable(path2) == 1 then
52+
return path2
53+
end
54+
end
55+
end
56+
57+
-- Global function that searches the path for the required file
58+
function find_required_path(module)
59+
-- Look at package.config for directory separator string (it's the first line)
60+
local sep = string.match(package.config, "^[^\n]")
61+
-- Properly change '.' to separator (probably '/' on *nix and '\' on Windows)
62+
local fname = vim.fn.substitute(module, "\\.", sep, "g")
63+
local f
64+
---- First search for lua modules
65+
f = include_paths(fname, "lua")
66+
if f then
67+
return f
68+
end
69+
-- This part is just for nvim modules
70+
f = include_rtpaths(fname, "lua")
71+
if f then
72+
return f
73+
end
74+
---- Now search for Fennel modules
75+
f = include_paths(fname, "fnl")
76+
if f then
77+
return f
78+
end
79+
-- This part is just for nvim modules
80+
f = include_rtpaths(fname, "fnl")
81+
if f then
82+
return f
83+
end
84+
end
85+
86+
-- Set options to open require with gf
87+
vim.opt_local.include = [=[\v<((do|load)file|require)\s*\(?['"]\zs[^'"]+\ze['"]]=]
88+
vim.opt_local.includeexpr = "v:lua.find_required_path(v:fname)"

ftplugin/man.lua

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vim.keymap.set("n", "q", ":q", { silent = true, buffer = 0 })

init.lua

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
vim.loader.enable()
2+
3+
require("akash.options")
4+
require("akash.keymaps")
5+
require("akash.lazy")
6+
require("akash.autocommands")
7+
--require("akash.macros")
8+
require("akash.icons")
9+
-- require("akash.which-key")
10+
11+
-- Enable autochdir
12+
vim.cmd([[set autochdir]])
13+
14+
-- Enable autochdir
15+
vim.o.autochdir = true
16+
17+
-- Bufferline
18+
require("bufferline").setup{}
19+
require("octo").setup{}
20+
21+
-- Discord
22+
require("presence").setup{}
23+

0 commit comments

Comments
 (0)