cleaned plugins
This commit is contained in:
parent
574ce0192b
commit
78eeb18ea6
|
|
@ -33,14 +33,6 @@ return require("packer").startup(
|
|||
end
|
||||
}
|
||||
|
||||
--[[ use {
|
||||
"NTBBloodbath/galaxyline.nvim",
|
||||
branch = "main",
|
||||
config = function()
|
||||
require "plugins/galaxyline"
|
||||
end,
|
||||
requires = {"kyazdani42/nvim-web-devicons"}
|
||||
} ]]
|
||||
use {
|
||||
"kyazdani42/nvim-tree.lua",
|
||||
after = "nvim-web-devicons",
|
||||
|
|
@ -49,7 +41,6 @@ return require("packer").startup(
|
|||
end,
|
||||
requires = {"kyazdani42/nvim-web-devicons", opt = true}
|
||||
}
|
||||
use "JoosepAlviste/nvim-ts-context-commentstring"
|
||||
use {
|
||||
"nvim-treesitter/playground",
|
||||
requires = {"nvim-treesitter/nvim-treesitter"}
|
||||
|
|
@ -134,7 +125,6 @@ return require("packer").startup(
|
|||
"weilbith/nvim-code-action-menu",
|
||||
cmd = "CodeActionMenu"
|
||||
}
|
||||
|
||||
use {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
config = function()
|
||||
|
|
@ -162,13 +152,6 @@ return require("packer").startup(
|
|||
require "plugins/diffview"
|
||||
end
|
||||
}
|
||||
-- use {
|
||||
-- "akinsho/bufferline.nvim",
|
||||
-- config = function()
|
||||
-- require "plugins/bufferline"
|
||||
-- end,
|
||||
-- requires = "kyazdani42/nvim-web-devicons"
|
||||
-- }
|
||||
use {
|
||||
"vuki656/package-info.nvim",
|
||||
config = function()
|
||||
|
|
@ -176,7 +159,6 @@ return require("packer").startup(
|
|||
end,
|
||||
requires = "MunifTanjim/nui.nvim"
|
||||
}
|
||||
use {"npxbr/glow.nvim", run = "GlowInstall"}
|
||||
use {
|
||||
"folke/todo-comments.nvim",
|
||||
requires = "nvim-lua/plenary.nvim",
|
||||
|
|
@ -193,7 +175,6 @@ return require("packer").startup(
|
|||
require("gitsigns").setup()
|
||||
end
|
||||
}
|
||||
use "jbyuki/venn.nvim"
|
||||
use "editorconfig/editorconfig-vim"
|
||||
use {
|
||||
"jameshiew/nvim-magic",
|
||||
|
|
@ -209,20 +190,6 @@ return require("packer").startup(
|
|||
"MunifTanjim/nui.nvim"
|
||||
}
|
||||
}
|
||||
|
||||
use {
|
||||
"mfussenegger/nvim-jdtls",
|
||||
config = function()
|
||||
vim.cmd(
|
||||
[[
|
||||
augroup jdtls_lsp
|
||||
autocmd!
|
||||
autocmd FileType java lua require'plugins/java-lsp'.setup()
|
||||
augroup end
|
||||
]]
|
||||
)
|
||||
end
|
||||
}
|
||||
use {
|
||||
"hrsh7th/nvim-cmp",
|
||||
config = function()
|
||||
|
|
@ -248,27 +215,6 @@ return require("packer").startup(
|
|||
end
|
||||
}
|
||||
use "aklt/plantuml-syntax"
|
||||
use {
|
||||
"NTBBloodbath/rest.nvim",
|
||||
requires = {"nvim-lua/plenary.nvim"},
|
||||
config = function()
|
||||
require("rest-nvim").setup(
|
||||
{
|
||||
-- Open request results in a horizontal split
|
||||
result_split_horizontal = false,
|
||||
-- Skip SSL verification, useful for unknown certificates
|
||||
skip_ssl_verification = false,
|
||||
-- Highlight request on run
|
||||
highlight = {
|
||||
enabled = true,
|
||||
timeout = 150
|
||||
},
|
||||
-- Jump to request line on run
|
||||
jump_to_request = false
|
||||
}
|
||||
)
|
||||
end
|
||||
}
|
||||
use {
|
||||
"github/copilot.vim",
|
||||
config = function()
|
||||
|
|
@ -302,10 +248,6 @@ return require("packer").startup(
|
|||
"nvim-lua/plenary.nvim"
|
||||
}
|
||||
}
|
||||
use {
|
||||
"SmiteshP/nvim-gps",
|
||||
requires = "nvim-treesitter/nvim-treesitter"
|
||||
}
|
||||
use {
|
||||
"rebelot/heirline.nvim",
|
||||
config = function()
|
||||
|
|
@ -313,7 +255,8 @@ return require("packer").startup(
|
|||
end,
|
||||
requires = {
|
||||
"kyazdani42/nvim-web-devicons",
|
||||
"SmiteshP/nvim-gps"
|
||||
"SmiteshP/nvim-gps",
|
||||
"nvim-treesitter/nvim-treesitter"
|
||||
},
|
||||
after = {
|
||||
"monokai.nvim",
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
require('nvim-ts-autotag').setup()
|
||||
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
diagnostics_indicator = function(count, level, diagnostics_dict, context)
|
||||
local s = " "
|
||||
for e, n in pairs(diagnostics_dict) do
|
||||
local sym = e == "error" and " " or (e == "warning" and " " or "")
|
||||
s = s .. n .. sym
|
||||
end
|
||||
return s
|
||||
end
|
||||
require "bufferline".setup {
|
||||
options = {
|
||||
always_show_bufferline = true,
|
||||
diagnostics_indicator = diagnostics_indicator,
|
||||
diagnostics = "nvim_lsp",
|
||||
separator_style = "thin"
|
||||
}
|
||||
}
|
||||
|
||||
vim.api.nvim_set_keymap("", "<A-1>", ":lua require'bufferline'.go_to_buffer(1)<CR>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-2>", ":lua require'bufferline'.go_to_buffer(2)<CR>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-3>", ":lua require'bufferline'.go_to_buffer(3)<CR>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-4>", ":lua require'bufferline'.go_to_buffer(4)<CR>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-5>", ":lua require'bufferline'.go_to_buffer(5)<CR>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-6>", ":lua require'bufferline'.go_to_buffer(6)<CR>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-7>", ":lua require'bufferline'.go_to_buffer(7)<CR>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-8>", ":lua require'bufferline'.go_to_buffer(8)<CR>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-9>", ":lua require'bufferline'.go_to_buffer(9)<CR>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-0>", ":lua require'bufferline'.go_to_buffer(10)<CR>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-Left>", "<C-w><Left>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-Up>", "<C-w><Up>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-Down>", "<C-w><Down>", {silent = true})
|
||||
vim.api.nvim_set_keymap("", "<A-Right>", "<C-w><Right>", {silent = true})
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
vim.o.completeopt = "menuone,noselect"
|
||||
require "compe".setup {
|
||||
enabled = true,
|
||||
autocomplete = true,
|
||||
debug = false,
|
||||
min_length = 1,
|
||||
preselect = "enable",
|
||||
throttle_time = 80,
|
||||
source_timeout = 200,
|
||||
incomplete_delay = 400,
|
||||
max_abbr_width = 100,
|
||||
max_kind_width = 100,
|
||||
max_menu_width = 100,
|
||||
documentation = true,
|
||||
source = {
|
||||
path = true,
|
||||
buffer = true,
|
||||
nvim_lsp = true,
|
||||
vsnip = false
|
||||
}
|
||||
}
|
||||
|
||||
vim.api.nvim_set_keymap("i", "<C-Space>", "compe#complete()", {silent = true, expr = true})
|
||||
vim.api.nvim_set_keymap("i", "<C-f>", "compe#complete()", {silent = true, expr = true})
|
||||
vim.api.nvim_set_keymap("i", "<CR>", "compe#confirm('<CR>')", {silent = true, expr = true})
|
||||
vim.api.nvim_set_keymap("i", "<C-e>", "compe#close('<C-e>')", {silent = true, expr = true})
|
||||
-- vim.api.nvim_set_keymap("i", "<C-f>", "compe#scroll({ 'delta': +4 })", {silent = true, expr = true})
|
||||
-- vim.api.nvim_set_keymap("i", "<C-d>", "compe#scroll({ 'delta': -4 })", {silent = true, expr = true})
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
local remap = vim.api.nvim_set_keymap
|
||||
local npairs = require("nvim-autopairs")
|
||||
|
||||
npairs.setup({map_bs = false})
|
||||
|
||||
vim.g.coq_settings = {
|
||||
clients = {
|
||||
lsp = {
|
||||
weight_adjust = 10
|
||||
}
|
||||
},
|
||||
keymap = {recommended = false, manual_complete = "<c-f>"},
|
||||
display = {
|
||||
preview = {
|
||||
positions = {
|
||||
east = 1,
|
||||
north = 2,
|
||||
south = 3,
|
||||
west = 4
|
||||
}
|
||||
},
|
||||
icons = {
|
||||
mappings = {
|
||||
Text = "",
|
||||
Method = "",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "ﰠ",
|
||||
Variable = "",
|
||||
Class = "ﴯ",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "ﰠ",
|
||||
Unit = "塞",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "פּ",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
Character = "",
|
||||
Number = "",
|
||||
Parameter = "",
|
||||
String = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- these mappings are coq recommended mappings unrelated to nvim-autopairs
|
||||
remap("i", "<esc>", [[pumvisible() ? "<c-e><esc>" : "<esc>"]], {expr = true, noremap = true})
|
||||
remap("i", "<c-c>", [[pumvisible() ? "<c-e><c-c>" : "<c-c>"]], {expr = true, noremap = true})
|
||||
remap("i", "<tab>", [[pumvisible() ? "<c-n>" : "<tab>"]], {expr = true, noremap = true})
|
||||
remap("i", "<s-tab>", [[pumvisible() ? "<c-p>" : "<bs>"]], {expr = true, noremap = true})
|
||||
|
||||
-- skip it, if you use another global object
|
||||
_G.MUtils = {}
|
||||
|
||||
MUtils.CR = function()
|
||||
if vim.fn.pumvisible() ~= 0 then
|
||||
if vim.fn.complete_info({"selected"}).selected ~= -1 then
|
||||
return npairs.esc("<c-y>")
|
||||
else
|
||||
return npairs.esc("<c-e>") .. npairs.autopairs_cr()
|
||||
end
|
||||
else
|
||||
return npairs.autopairs_cr()
|
||||
end
|
||||
end
|
||||
remap("i", "<cr>", "v:lua.MUtils.CR()", {expr = true, noremap = true})
|
||||
|
||||
MUtils.BS = function()
|
||||
if vim.fn.pumvisible() ~= 0 and vim.fn.complete_info({"mode"}).mode == "eval" then
|
||||
return npairs.esc("<c-e>") .. npairs.autopairs_bs()
|
||||
else
|
||||
return npairs.autopairs_bs()
|
||||
end
|
||||
end
|
||||
remap("i", "<bs>", "v:lua.MUtils.BS()", {expr = true, noremap = true})
|
||||
|
|
@ -1,245 +0,0 @@
|
|||
local gl = require("galaxyline")
|
||||
local colors = require("galaxyline.themes.colors").get_color
|
||||
local theme = require("monokai")
|
||||
local condition = require("galaxyline.condition")
|
||||
local gls = gl.section
|
||||
gl.short_line_list = {"NvimTree", "vista", "dbui", "packer"}
|
||||
local color_bg = "#333842"
|
||||
|
||||
gls.left[2] = {
|
||||
ViMode = {
|
||||
provider = function()
|
||||
-- auto change color according the vim mode
|
||||
local mode_color = {
|
||||
n = colors("green"),
|
||||
i = colors("red"),
|
||||
v = colors("blue"),
|
||||
[""] = colors("blue"),
|
||||
V = colors("blue"),
|
||||
c = colors("magenta"),
|
||||
no = colors("red"),
|
||||
s = colors("orange"),
|
||||
S = colors("orange"),
|
||||
[""] = colors("orange"),
|
||||
ic = colors("yellow"),
|
||||
R = colors("violet"),
|
||||
Rv = colors("violet"),
|
||||
cv = colors("red"),
|
||||
ce = colors("red"),
|
||||
r = colors("cyan"),
|
||||
rm = colors("cyan"),
|
||||
["r?"] = colors("cyan"),
|
||||
["!"] = colors("red"),
|
||||
t = colors("red")
|
||||
}
|
||||
local mode_map = {
|
||||
["n"] = "NORMAL ",
|
||||
["no"] = "N·OPERATOR PENDING ",
|
||||
["v"] = "VISUAL ",
|
||||
["V"] = "V·LINE ",
|
||||
[""] = "V·BLOCK ",
|
||||
["s"] = "SELECT ",
|
||||
["S"] = "S·LINE ",
|
||||
[""] = "S·BLOCK ",
|
||||
["i"] = "INSERT ",
|
||||
["R"] = "REPLACE ",
|
||||
["Rv"] = "V·REPLACE ",
|
||||
["c"] = "COMMAND ",
|
||||
["cv"] = "VIM EX ",
|
||||
["ce"] = "EX ",
|
||||
["r"] = "PROMPT ",
|
||||
["rm"] = "MORE ",
|
||||
["r?"] = "CONFIRM ",
|
||||
["!"] = "SHELL ",
|
||||
["t"] = "TERMINAL "
|
||||
}
|
||||
vim.api.nvim_command("hi GalaxyViMode guibg=" .. mode_color[vim.fn.mode()]())
|
||||
return " " .. mode_map[vim.fn.mode()]
|
||||
end,
|
||||
separator = " ",
|
||||
separator_highlight = {nil, color_bg},
|
||||
highlight = {color_bg, color_bg, "bold"}
|
||||
}
|
||||
}
|
||||
gls.left[3] = {
|
||||
Macro = {
|
||||
provider = function()
|
||||
local reg = vim.fn.reg_recording()
|
||||
|
||||
if (reg == nil) or (reg == "") then
|
||||
return ""
|
||||
else
|
||||
return " " .. vim.call("reg_recording") .. " "
|
||||
end
|
||||
end,
|
||||
highlight = {colors("red"), color_bg}
|
||||
}
|
||||
}
|
||||
gls.left[5] = {
|
||||
FileIcon = {
|
||||
provider = "FileIcon",
|
||||
condition = condition.buffer_not_empty,
|
||||
highlight = {require("galaxyline.providers.fileinfo").get_file_icon_color, color_bg}
|
||||
}
|
||||
}
|
||||
|
||||
gls.left[6] = {
|
||||
FileName = {
|
||||
provider = "FileName",
|
||||
condition = condition.buffer_not_empty,
|
||||
highlight = {colors("magenta"), color_bg, "bold"}
|
||||
}
|
||||
}
|
||||
|
||||
gls.left[7] = {
|
||||
LineInfo = {
|
||||
provider = "LineColumn",
|
||||
separator = " ",
|
||||
separator_highlight = {"NONE", color_bg},
|
||||
highlight = {colors("fg"), color_bg}
|
||||
}
|
||||
}
|
||||
|
||||
gls.left[8] = {
|
||||
PerCent = {
|
||||
provider = "LinePercent",
|
||||
separator = " ",
|
||||
separator_highlight = {"NONE", color_bg},
|
||||
highlight = {colors("fg"), color_bg, "bold"}
|
||||
}
|
||||
}
|
||||
|
||||
gls.left[9] = {
|
||||
DiagnosticError = {
|
||||
provider = "DiagnosticError",
|
||||
icon = " ",
|
||||
highlight = {colors("red"), color_bg}
|
||||
}
|
||||
}
|
||||
gls.left[10] = {
|
||||
DiagnosticWarn = {
|
||||
provider = "DiagnosticWarn",
|
||||
icon = " ",
|
||||
highlight = {colors("yellow"), color_bg}
|
||||
}
|
||||
}
|
||||
|
||||
gls.left[11] = {
|
||||
DiagnosticHint = {
|
||||
provider = "DiagnosticHint",
|
||||
icon = " ",
|
||||
highlight = {colors("cyan"), color_bg}
|
||||
}
|
||||
}
|
||||
|
||||
gls.left[12] = {
|
||||
DiagnosticInfo = {
|
||||
provider = "DiagnosticInfo",
|
||||
icon = " ",
|
||||
highlight = {colors("blue"), color_bg}
|
||||
}
|
||||
}
|
||||
|
||||
gls.right[0] = {
|
||||
WordCount = {
|
||||
provider = function()
|
||||
local wc = vim.api.nvim_eval("wordcount()")
|
||||
if wc["visual_words"] then
|
||||
return wc["visual_words"]
|
||||
else
|
||||
return wc["words"]
|
||||
end
|
||||
end,
|
||||
icon = " ",
|
||||
highlight = {colors("green"), color_bg}
|
||||
}
|
||||
}
|
||||
gls.right[1] = {
|
||||
FileEncode = {
|
||||
provider = "FileEncode",
|
||||
condition = condition.hide_in_width,
|
||||
separator = " ",
|
||||
separator_highlight = {"NONE", color_bg},
|
||||
highlight = {colors("green"), color_bg, "bold"}
|
||||
}
|
||||
}
|
||||
|
||||
gls.right[2] = {
|
||||
FileFormat = {
|
||||
provider = "FileFormat",
|
||||
condition = condition.hide_in_width,
|
||||
separator = " ",
|
||||
separator_highlight = {"NONE", color_bg},
|
||||
highlight = {colors("green"), color_bg, "bold"}
|
||||
}
|
||||
}
|
||||
|
||||
gls.right[3] = {
|
||||
GitIcon = {
|
||||
provider = function()
|
||||
return " "
|
||||
end,
|
||||
condition = condition.check_git_workspace,
|
||||
separator = " ",
|
||||
separator_highlight = {"NONE", color_bg},
|
||||
highlight = {colors("violet"), color_bg, "bold"}
|
||||
}
|
||||
}
|
||||
|
||||
gls.right[4] = {
|
||||
GitBranch = {
|
||||
provider = "GitBranch",
|
||||
condition = condition.check_git_workspace,
|
||||
highlight = {colors("violet"), color_bg, "bold"}
|
||||
}
|
||||
}
|
||||
|
||||
gls.right[5] = {
|
||||
DiffAdd = {
|
||||
provider = "DiffAdd",
|
||||
separator = " ",
|
||||
separator_highlight = {nil, color_bg},
|
||||
condition = condition.hide_in_width,
|
||||
icon = " ",
|
||||
highlight = {colors("green"), color_bg}
|
||||
}
|
||||
}
|
||||
gls.right[6] = {
|
||||
DiffModified = {
|
||||
provider = "DiffModified",
|
||||
condition = condition.hide_in_width,
|
||||
icon = " ",
|
||||
highlight = {colors("orane"), color_bg}
|
||||
}
|
||||
}
|
||||
gls.right[7] = {
|
||||
DiffRemove = {
|
||||
provider = "DiffRemove",
|
||||
condition = condition.hide_in_width,
|
||||
icon = " ",
|
||||
highlight = {colors("red"), color_bg}
|
||||
}
|
||||
}
|
||||
|
||||
-- File type name
|
||||
-- --------------
|
||||
|
||||
gls.short_line_left[1] = {
|
||||
ShortLineFileName = {
|
||||
provider = "FileName",
|
||||
condition = condition.buffer_not_empty,
|
||||
highlight = {colors("fg"), color_bg},
|
||||
separator = " ",
|
||||
separator_highlight = {nil, color_bg}
|
||||
}
|
||||
}
|
||||
|
||||
-- Buffer icon
|
||||
-- -----------
|
||||
|
||||
gls.short_line_right[1] = {
|
||||
BufferIcon = {
|
||||
provider = "BufferIcon",
|
||||
highlight = {colors("fg"), color_bg}
|
||||
}
|
||||
}
|
||||
|
|
@ -418,7 +418,7 @@ local TerminalStatusline = {
|
|||
}
|
||||
|
||||
local StatusLines = {
|
||||
init = utils.pick_child_on_condition,
|
||||
fallthrough = false,
|
||||
SpecialStatusline,
|
||||
TerminalStatusline,
|
||||
DefaultStatusline
|
||||
|
|
@ -427,7 +427,7 @@ local StatusLines = {
|
|||
local GSpace = {provider = " ", hl = {bg = colors.bg}}
|
||||
|
||||
local WinBars = {
|
||||
init = utils.pick_child_on_condition,
|
||||
fallthrough = false,
|
||||
{
|
||||
-- Hide the winbar for special buffers
|
||||
condition = function()
|
||||
|
|
|
|||
|
|
@ -1,292 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
local on_attach = function(client, bufnr)
|
||||
require "jdtls.setup".add_commands()
|
||||
-- require "jdtls".setup_dap()
|
||||
-- require "lsp-status".register_progress()
|
||||
require "compe".setup {
|
||||
enabled = true,
|
||||
autocomplete = true,
|
||||
debug = false,
|
||||
min_length = 1,
|
||||
preselect = "enable",
|
||||
throttle_time = 80,
|
||||
source_timeout = 200,
|
||||
incomplete_delay = 400,
|
||||
max_abbr_width = 100,
|
||||
max_kind_width = 100,
|
||||
max_menu_width = 100,
|
||||
documentation = true,
|
||||
source = {
|
||||
path = true,
|
||||
buffer = true,
|
||||
calc = true,
|
||||
vsnip = false,
|
||||
nvim_lsp = true,
|
||||
nvim_lua = true,
|
||||
spell = true,
|
||||
tags = true,
|
||||
snippets_nvim = false,
|
||||
treesitter = true
|
||||
}
|
||||
}
|
||||
|
||||
require "lspkind".init()
|
||||
|
||||
require "formatter".setup {
|
||||
filetype = {
|
||||
java = {
|
||||
function()
|
||||
return {
|
||||
exe = "java",
|
||||
args = {
|
||||
"--add-exports",
|
||||
"jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
||||
"--add-exports",
|
||||
"jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
||||
"--add-exports",
|
||||
"jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
|
||||
"--add-exports",
|
||||
"jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
||||
"--add-exports",
|
||||
"jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
||||
"-jar",
|
||||
os.getenv("HOME") .. "/.local/jars/google-java-format.jar",
|
||||
vim.api.nvim_buf_get_name(0)
|
||||
},
|
||||
stdin = true
|
||||
}
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vim.api.nvim_exec(
|
||||
[[
|
||||
augroup FormatAutogroup
|
||||
autocmd!
|
||||
autocmd BufWritePost *.java FormatWrite
|
||||
augroup end
|
||||
]],
|
||||
true
|
||||
)
|
||||
|
||||
local function buf_set_keymap(...)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
end
|
||||
local function buf_set_option(...)
|
||||
vim.api.nvim_buf_set_option(bufnr, ...)
|
||||
end
|
||||
|
||||
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
|
||||
-- Mappings.
|
||||
local opts = {noremap = true, silent = true}
|
||||
buf_set_keymap("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||
buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||
buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||
buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||
buf_set_keymap("n", "<F2>", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>a", "<Cmd>lua require('jdtls').code_action()<CR>", opts)
|
||||
buf_set_keymap("v", "<leader>a", "<Esc><Cmd>lua require('jdtls').code_action(true)<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>r", "<Cmd>lua require('jdtls').code_action(false, 'refactor')<CR>", opts)
|
||||
buf_set_keymap("n", "gr", '<cmd>lua vim.lsp.buf.references() && vim.cmd("copen")<CR>', opts)
|
||||
buf_set_keymap("n", "<leader>d", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
|
||||
buf_set_keymap("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts)
|
||||
buf_set_keymap("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
|
||||
-- Java specific
|
||||
buf_set_keymap("n", "<leader>rt", "<Cmd>lua require'jdtls'.test_class()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>rn", "<Cmd>lua require'jdtls'.test_nearest_method()<CR>", opts)
|
||||
buf_set_keymap("v", "<leader>ev", "<Esc><Cmd>lua require('jdtls').extract_variable(true)<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>ev", "<Cmd>lua require('jdtls').extract_variable()<CR>", opts)
|
||||
buf_set_keymap("v", "<leader>em", "<Esc><Cmd>lua require('jdtls').extract_method(true)<CR>", opts)
|
||||
end
|
||||
|
||||
local root_markers = {"gradlew", "pom.xml"}
|
||||
local root_dir = require("jdtls.setup").find_root(root_markers)
|
||||
local home = os.getenv("HOME")
|
||||
|
||||
local capabilities = {
|
||||
workspace = {
|
||||
configuration = true
|
||||
},
|
||||
textDocument = {
|
||||
completion = {
|
||||
completionItem = {
|
||||
snippetSupport = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local workspace_folder = home .. "/.workspace" .. vim.fn.fnamemodify(root_dir, ":p:h:t")
|
||||
local config = {
|
||||
flags = {
|
||||
allow_incremental_sync = true
|
||||
},
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach
|
||||
}
|
||||
|
||||
config.settings = {
|
||||
["java.format.settings.url"] = home .. "/.config/nvim/language-servers/java-google-formatter.xml",
|
||||
["java.format.settings.profile"] = "GoogleStyle",
|
||||
java = {
|
||||
signatureHelp = {enabled = true},
|
||||
contentProvider = {preferred = "fernflower"},
|
||||
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.*"
|
||||
}
|
||||
},
|
||||
sources = {
|
||||
organizeImports = {
|
||||
starThreshold = 9999,
|
||||
staticStarThreshold = 9999
|
||||
}
|
||||
},
|
||||
codeGeneration = {
|
||||
toString = {
|
||||
template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
config.cmd = {"java-lsp.sh", workspace_folder}
|
||||
config.on_attach = on_attach
|
||||
config.on_init = function(client, _)
|
||||
client.notify("workspace/didChangeConfiguration", {settings = config.settings})
|
||||
end
|
||||
|
||||
-- local jar_patterns = {
|
||||
-- '/dev/microsoft/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar',
|
||||
-- '/dev/dgileadi/vscode-java-decompiler/server/*.jar',
|
||||
-- '/dev/microsoft/vscode-java-test/server/*.jar',
|
||||
-- }
|
||||
|
||||
-- local bundles = {}
|
||||
-- for _, jar_pattern in ipairs(jar_patterns) do
|
||||
-- for _, bundle in ipairs(vim.split(vim.fn.glob(home .. jar_pattern), '\n')) do
|
||||
-- if not vim.endswith(bundle, 'com.microsoft.java.test.runner.jar') then
|
||||
-- table.insert(bundles, bundle)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
local extendedClientCapabilities = require "jdtls".extendedClientCapabilities
|
||||
extendedClientCapabilities.resolveAdditionalTextEditsSupport = true
|
||||
config.init_options = {
|
||||
-- bundles = bundles;
|
||||
extendedClientCapabilities = extendedClientCapabilities
|
||||
}
|
||||
|
||||
-- UI
|
||||
--[[ local finders = require "telescope.finders"
|
||||
local sorters = require "telescope.sorters"
|
||||
local actions = require "telescope.actions"
|
||||
local pickers = require "telescope.pickers"
|
||||
require("jdtls.ui").pick_one_async = function(items, prompt, label_fn, cb)
|
||||
local opts = {}
|
||||
pickers.new(
|
||||
opts,
|
||||
{
|
||||
prompt_title = prompt,
|
||||
finder = finders.new_table {
|
||||
results = items,
|
||||
entry_maker = function(entry)
|
||||
return {
|
||||
value = entry,
|
||||
display = label_fn(entry),
|
||||
ordinal = label_fn(entry)
|
||||
}
|
||||
end
|
||||
},
|
||||
sorter = sorters.get_generic_fuzzy_sorter(),
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
actions.goto_file_selection_edit:replace(
|
||||
function()
|
||||
local selection = actions.get_selected_entry(prompt_bufnr)
|
||||
actions.close(prompt_bufnr)
|
||||
|
||||
cb(selection.value)
|
||||
end
|
||||
)
|
||||
|
||||
return true
|
||||
end
|
||||
}
|
||||
):find()
|
||||
end
|
||||
]]
|
||||
-- Server
|
||||
require("jdtls").start_or_attach(config)
|
||||
end
|
||||
|
||||
local function buf_set_keymap(...)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
end
|
||||
local opts = {noremap = true, silent = true}
|
||||
buf_set_keymap("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||
buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||
buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||
buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||
buf_set_keymap("n", "<F2>", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>a", "<Cmd>lua require('jdtls').code_action()<CR>", opts)
|
||||
buf_set_keymap("v", "<leader>a", "<Esc><Cmd>lua require('jdtls').code_action(true)<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>r", "<Cmd>lua require('jdtls').code_action(false, 'refactor')<CR>", opts)
|
||||
buf_set_keymap("n", "gr", '<cmd>lua vim.lsp.buf.references() && vim.cmd("copen")<CR>', opts)
|
||||
buf_set_keymap("n", "<leader>d", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
|
||||
buf_set_keymap("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts)
|
||||
buf_set_keymap("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>fc", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
||||
-- Java specific
|
||||
buf_set_keymap("n", "<leader>rt", "<Cmd>lua require'jdtls'.test_class()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>rn", "<Cmd>lua require'jdtls'.test_nearest_method()<CR>", opts)
|
||||
buf_set_keymap("v", "<leader>ev", "<Esc><Cmd>lua require('jdtls').extract_variable(true)<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>ev", "<Cmd>lua require('jdtls').extract_variable()<CR>", opts)
|
||||
buf_set_keymap("v", "<leader>em", "<Esc><Cmd>lua require('jdtls').extract_method(true)<CR>", opts)
|
||||
vim.fn.sign_define(
|
||||
"DiagnosticSignError",
|
||||
{texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"}
|
||||
)
|
||||
vim.fn.sign_define(
|
||||
"DiagnosticSignWarning",
|
||||
{texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"}
|
||||
)
|
||||
vim.fn.sign_define(
|
||||
"DiagnosticSignWarn",
|
||||
{texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"}
|
||||
)
|
||||
vim.fn.sign_define(
|
||||
"DiagnosticSignHint",
|
||||
{texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"}
|
||||
)
|
||||
vim.fn.sign_define(
|
||||
"DiagnosticSignInformation",
|
||||
{texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"}
|
||||
)
|
||||
vim.fn.sign_define(
|
||||
"DiagnosticSignInfo",
|
||||
{texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"}
|
||||
)
|
||||
|
||||
return M
|
||||
Loading…
Reference in New Issue