feat: support java
fix: nvim tree filter .gitignore support: rust language
This commit is contained in:
121
ftplugin/java.lua
Normal file
121
ftplugin/java.lua
Normal file
@@ -0,0 +1,121 @@
|
||||
function IsDirectoryExist(dirname)
|
||||
return os.rename(dirname, dirname) and true or false
|
||||
end
|
||||
|
||||
local jdtls = require("jdtls")
|
||||
local root_markers = { ".git", "mvnw", "gradlew", "pom.xml", "build.gradle" }
|
||||
local root_dir = require("jdtls.setup").find_root(root_markers)
|
||||
if root_dir == "" then
|
||||
return
|
||||
end
|
||||
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
|
||||
local home = os.getenv("HOME")
|
||||
local jdtls_home = home .. "/.jdtls"
|
||||
local plugins_home = jdtls_home .. "/plugins"
|
||||
local workspace = jdtls_home .. "/workspace/" .. project_name
|
||||
|
||||
-- create when workspace not exist
|
||||
if not IsDirectoryExist(workspace) then
|
||||
os.execute("mkdir " .. workspace)
|
||||
end
|
||||
|
||||
local launcher = plugins_home .. "/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar"
|
||||
local configuration = jdtls_home .. "/config_linux"
|
||||
if vim.loop.os_uname().sysname == "Windows" then
|
||||
configuration = jdtls_home .. "\\config_win"
|
||||
end
|
||||
|
||||
local config = {
|
||||
flags = {
|
||||
debounce_text_changes = 80,
|
||||
},
|
||||
on_attach = common_lsp_on_attach,
|
||||
cmd = {
|
||||
"java",
|
||||
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
|
||||
"-Dosgi.bundles.defaultStartLevel=4",
|
||||
"-Declipse.product=org.eclipse.jdt.ls.core.product",
|
||||
"-Dlog.protocol=true",
|
||||
"-Dlog.level=ALL",
|
||||
"-Xmx1g",
|
||||
"--add-modules=ALL-SYSTEM",
|
||||
"--add-opens",
|
||||
"java.base/java.util=ALL-UNNAMED",
|
||||
"--add-opens",
|
||||
"java.base/java.lang=ALL-UNNAMED",
|
||||
"-javaagent:" .. jdtls_home .. "/bin/lombok.jar",
|
||||
"-jar",
|
||||
launcher,
|
||||
"-configuration",
|
||||
configuration,
|
||||
"-data",
|
||||
workspace,
|
||||
},
|
||||
root_dir = root_dir,
|
||||
settings = {
|
||||
java = {
|
||||
maven = {
|
||||
downloadSources = true,
|
||||
},
|
||||
eclipse = {
|
||||
downloadSources = true,
|
||||
},
|
||||
implementationsCodeLens = {
|
||||
enabled = true,
|
||||
},
|
||||
referencesCodeLens = {
|
||||
enabled = true,
|
||||
},
|
||||
references = {
|
||||
includeDecompiledSources = true,
|
||||
},
|
||||
format = {
|
||||
enabled = true,
|
||||
settings = {
|
||||
url = vim.fn.stdpath("config") .. "intellij-java-google-style.xml",
|
||||
profile = "GoogleStyle",
|
||||
},
|
||||
},
|
||||
signatureHelp = { enabled = true },
|
||||
contentProvider = { preferred = "fernflower" }, -- Use fernflower to decompile library code
|
||||
completion = {
|
||||
favoriteStaticMembers = {
|
||||
"org.hamcrest.MatcherAssert.assertThat",
|
||||
"org.hamcrest.Matchers.*",
|
||||
"org.hamcrest.CoreMatchers.*",
|
||||
"org.junit.jupiter.api.Assertions.*",
|
||||
"java.util.Objects.requireNonNull",
|
||||
"java.util.Objects.requireNonNullElse",
|
||||
"org.mockito.Mockito.*",
|
||||
},
|
||||
filteredTypes = {
|
||||
"com.sun.*",
|
||||
"io.micrometer.shaded.*",
|
||||
"java.awt.*",
|
||||
"jdk.*",
|
||||
"sun.*",
|
||||
},
|
||||
},
|
||||
sources = {
|
||||
organizeImports = {
|
||||
starThreshold = 9999,
|
||||
staticStarThreshold = 9999,
|
||||
},
|
||||
},
|
||||
codeGeneration = {
|
||||
toString = {
|
||||
template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}",
|
||||
},
|
||||
hashCodeEquals = {
|
||||
useJava7Objects = true,
|
||||
},
|
||||
useBlocks = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
init_options = {
|
||||
bundles = {},
|
||||
},
|
||||
}
|
||||
jdtls.start_or_attach(config)
|
||||
@@ -1 +0,0 @@
|
||||
vnoremap <silent><buffer> D :<c-u>call SurroundVaddPairs("/** ", " */")<cr>
|
||||
@@ -1,51 +0,0 @@
|
||||
hi MDTask ctermfg=1
|
||||
hi MDDoneText ctermfg=37 cterm=italic,strikethrough
|
||||
hi MDTodoText cterm=NONE
|
||||
hi MDDoneDate cterm=strikethrough ctermfg=71
|
||||
hi MDTodoDate ctermfg=71
|
||||
hi Deadline ctermfg=162 cterm=bold,underline
|
||||
hi NearDeadline ctermfg=178 cterm=bold
|
||||
au FileType markdown syn match markdownError "\w\@<=\w\@="
|
||||
au FileType markdown syn match MDDoneDate /[SD]:\d\{4\}\([\/-]\d\d\)\{2\}/ contained
|
||||
au FileType markdown syn match MDTodoDate /[SD]:\d\{4\}\([\/-]\d\d\)\{2\}/ contained
|
||||
au FileType markdown syn match MDDoneText /- \[x\] \zs.*/ contains=MDDoneDate contained
|
||||
au FileType markdown syn match MDTodoText /- \[ \] \zs.*/ contains=MDTodoDate contained
|
||||
au FileType markdown syn match MDTask /- \[\(x\| \)\] .*/ contains=MDDoneText,MDTodoText
|
||||
au FileType markdown call matchadd('Deadline', 'D:'.strftime("%Y-%m-%d"))
|
||||
au FileType markdown call matchadd('NearDeadline', 'D:'.strftime("%Y-%m-%d", localtime() + 3600 * 24))
|
||||
au FileType markdown call matchadd('NearDeadline', 'D:'.strftime("%Y-%m-%d", localtime() + 3600 * 48))
|
||||
|
||||
let b:md_block = '```'
|
||||
setlocal shiftwidth=2
|
||||
setlocal softtabstop=2
|
||||
setlocal tabstop=2
|
||||
nnoremap <silent><buffer> <CR> :call <SID>toggleTodoStatus()<CR><CR>
|
||||
nnoremap <silent><buffer> <2-LeftMouse> :call <SID>toggleTodoStatus()<CR>:w<CR><2-LeftMouse>
|
||||
vnoremap <silent><buffer> B :<c-u>call SurroundVaddPairs("**", "**")<cr>
|
||||
vnoremap <silent><buffer> I :<c-u>call SurroundVaddPairs("*", "*")<cr>
|
||||
vnoremap <silent><buffer> T :<c-u>call SurroundVaddPairs("- [ ] ", "")<cr>
|
||||
vnoremap <silent><buffer> ` :<c-u>call SurroundVaddPairs("`", "`")<cr>
|
||||
vnoremap <silent><buffer> C :<c-u>call SurroundVaddPairs("```plaintext", "```")<cr>
|
||||
|
||||
fun! s:toggleTodoStatus()
|
||||
let line = getline('.')
|
||||
if line =~ glob2regpat('*- \[ \]*')
|
||||
call setline('.', substitute(line, '\[ \]', '[x]', ''))
|
||||
elseif line =~ glob2regpat('*- \[x\]*')
|
||||
call setline('.', substitute(line, '\[x\]', '[ ]', ''))
|
||||
endif
|
||||
endf
|
||||
|
||||
nnoremap <silent><buffer> <F6> :call <SID>toggleMPTheme()<CR>
|
||||
inoremap <silent><buffer> <F6> <ESC>:call <SID>toggleMPTheme()<CR>
|
||||
fun! s:toggleMPTheme()
|
||||
if g:mkdp_theme == 'dark'
|
||||
let g:mkdp_theme = 'light'
|
||||
else
|
||||
let g:mkdp_theme = 'dark'
|
||||
endif
|
||||
|
||||
exec 'MarkdownPreviewStop'
|
||||
sleep 1
|
||||
exec 'MarkdownPreview'
|
||||
endf
|
||||
@@ -1 +0,0 @@
|
||||
let g:omni_sql_no_default_maps = 1
|
||||
@@ -1 +0,0 @@
|
||||
vnoremap <silent><buffer> D :<c-u>call SurroundVaddPairs("/** ", " */")<cr>
|
||||
@@ -1 +0,0 @@
|
||||
let g:omni_sql_no_default_maps = 1
|
||||
@@ -1 +0,0 @@
|
||||
vnoremap <silent><buffer> D :<c-u>call SurroundVaddPairs("/** ", " */")<cr>
|
||||
@@ -1,4 +0,0 @@
|
||||
augroup vue
|
||||
au!
|
||||
autocmd BufWritePre *.vue :call CocAction('format')
|
||||
augroup END
|
||||
Reference in New Issue
Block a user