Skip to content

V2 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 21, 2024
Merged

V2 #7

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
456 changes: 0 additions & 456 deletions lua/java-deps.lua

This file was deleted.

113 changes: 33 additions & 80 deletions lua/java-deps/config.lua
Original file line number Diff line number Diff line change
@@ -1,96 +1,49 @@
local M = {
debug = false,
jdtls_name = "jdtls",
options = {
show_guides = true,
show_path_details = true,
auto_close = false,
width = 32,
relative_width = true,
show_numbers = false,
show_relative_numbers = false,
preview_bg_highlight = "Pmenu",
winblend = 0,
request_timeout = 3000,
autofold_depth = 99,
fold_markers = { "", "" },
position = "right",
wrap = false,
hierarchical_view = true,
keymaps = { -- These keymaps can be a string or a table for multiple keys
open_file = "o",
close = { "<Esc>", "q" },
show_help = "?",
toggle_preview = "K",
fold = "h",
unfold = "l",
fold_all = "W",
unfold_all = "E",
fold_reset = "R",
},
symbols = {
Workspace = { icon = "", hl = "@text.uri" },
Project = { icon = "", hl = "@text.uri" },
PackageRoot = { icon = "", hl = "@text.uri" },
Package = { icon = "", hl = "@namespace" },
PrimaryType = { icon = "󰠱", hl = "@type" },
CompilationUnit = { icon = "", hl = "@text.uri" },
ClassFile = { icon = "", hl = "@text.uri" },
Container = { icon = "󰆧", hl = "@text.uri" },
Folder = { icon = "󰉋", hl = "@method" },
File = { icon = "󰈙", hl = "@method" },

CLASS = { icon = "󰠱", hl = "@class" },
ENUM = { icon = "", hl = "@enum" },
INTERFACE = { icon = "", hl = "@interface" },
JAR = { icon = "", hl = "@conditional" },
},
symbol_blacklist = {},
},
jdtls_name = "jdtls",
options = {
show_guides = true,
auto_close = false,
width = 40,
show_numbers = false,
show_relative_numbers = false,
preview_bg_highlight = "Pmenu",
winblend = 0,
fold_markers = { "", "" },
position = "right",
wrap = false,
hierarchical_view = true,
keymaps = {
close = "q",
toggle_fold = "o",
},
symbols = {
icons = {},
},
},
}
M.setup = function(config)
if config then
M = vim.tbl_extend("force", M, config)
end
if config then
M = vim.tbl_extend("force", M, config)
end
end

function M.has_numbers()
return M.options.show_numbers or M.options.show_relative_numbers
end
local function has_value(tab, val)
for _, value in ipairs(tab) do
if value == val then
return true
end
end

return false
end

function M.is_symbol_blacklisted(kind)
if kind == nil then
return false
end
return has_value(M.options.symbol_blacklist, kind)
return M.options.show_numbers or M.options.show_relative_numbers
end

function M.show_help()
print("Current keymaps:")
print(vim.inspect(M.options.keymaps))
print("Current keymaps:")
print(vim.inspect(M.options.keymaps))
end

function M.get_split_command()
if M.options.position == "left" then
return "topleft vs"
else
return "botright vs"
end
if M.options.position == "left" then
return "topleft vs"
else
return "botright vs"
end
end
function M.get_window_width()
if M.options.relative_width then
return math.ceil(vim.o.columns * (M.options.width / 100))
else
return M.options.width
end
return M.options.width
end
return M
33 changes: 0 additions & 33 deletions lua/java-deps/context.lua

This file was deleted.

44 changes: 0 additions & 44 deletions lua/java-deps/folding.lua

This file was deleted.

34 changes: 34 additions & 0 deletions lua/java-deps/highlight.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
local M = {
items = {
nsid = vim.api.nvim_create_namespace("java-deps-items"),
highlights = {
LineGuide = { link = "Comment" },
},
},
}

M.init_hl = function()
local ihlf = function(hls)
for name, hl in pairs(hls.highlights) do
if vim.fn.hlexists("JavaDeps" .. name) == 0 then
vim.api.nvim_set_hl(0, "JavaDeps" .. name, { link = hl.link })
end
end
end
ihlf(M.items)
end
M.clear_all_ns = function(bufnr)
vim.api.nvim_buf_clear_namespace(bufnr, -1, 0, -1)
end

---@param bufnr number
---@param hl_info table
---@param nodes TreeItem[]
function M.add_item_highlights(bufnr, hl_info, nodes)
for _, line_hl in ipairs(hl_info) do
local line, hl_start, hl_end, hl_type = unpack(line_hl)
vim.api.nvim_buf_add_highlight(bufnr, M.items.nsid, hl_type, line - 1, hl_start, hl_end)
end
end

return M
42 changes: 42 additions & 0 deletions lua/java-deps/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
local config = require("java-deps.config")
local View = require("java-deps.view")
local highlight = require("java-deps.highlight")
-- debug
vim.g.java_deps = {
debug = true,
}

local M = {
view = nil,
state = {
code_buf = nil,
code_win = nil,
},
}

function M.toggle_outline()
if M.view:is_open() then
M.close_outline()
else
M.open_outline()
end
end

function M.open_outline()
if not M.view:is_open() then
M.view:open()
M.view:revealPaths()
end
end

function M.close_outline()
M.view:close()
end

function M.setup(opts)
config.setup(opts)
M.view = View:new()
highlight.init_hl()
end

return M
22 changes: 22 additions & 0 deletions lua/java-deps/java/ContainerEntryKind.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local INodeData = require("java-deps.java.nodeData").INodeData
local M = {}

---@enum ContainerEntryKind
M.ContainerEntryKind = {
CPE_LIBRARY = 1,
CPE_PROJECT = 2,
CPE_SOURCE = 3,
CPE_VARIABLE = 4,
CPE_CONTAINER = 5,
}
---@class IContainerNodeData: INodeData
---@field entryKind ContainerEntryKind
local IContainerNodeData = INodeData:new()
IContainerNodeData.__index = IContainerNodeData

function IContainerNodeData:new()
return setmetatable(INodeData:new(), self)
end
M.IContainerNodeData = IContainerNodeData

return M
34 changes: 34 additions & 0 deletions lua/java-deps/java/IPackageRootNodeData.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
local INodeData = require("java-deps.java.nodeData").INodeData
local M = {}
---@enum PackageRootKind
M.PackageRootKind = {
K_SOURCE = 1,
K_BINARY = 2,
}

---@class IPackageRootNodeData:INodeData
---@field entryKind PackageRootKind
---@field attributes table<string, string>
local IPackageRootNodeData = INodeData:new()
IPackageRootNodeData.__index = IPackageRootNodeData
function IPackageRootNodeData:new()
return setmetatable(INodeData:new(), self)
end

---@param node INodeData
---@return IPackageRootNodeData
function IPackageRootNodeData:form(node)
return setmetatable(node, self)
end

function IPackageRootNodeData:getEntryKind()
return self.entryKind
end

function IPackageRootNodeData:getAttributes()
return self.attributes
end

M.IPackageRootNodeData = IPackageRootNodeData

return M
Loading