v1.0.0
This commit is contained in:
30
lua/util/icon.lua
Normal file
30
lua/util/icon.lua
Normal file
@ -0,0 +1,30 @@
|
||||
local M = {
|
||||
diagnostics = {
|
||||
error = "",
|
||||
warn = "",
|
||||
info = "",
|
||||
hint = "",
|
||||
},
|
||||
}
|
||||
|
||||
function M.sign_defines()
|
||||
local icons = M.diagnostics
|
||||
-- error
|
||||
local sign_diag_error = { text = icons.error, texthl = "DiagnosticSignError" }
|
||||
vim.fn.sign_define("DiagnosticSignError", sign_diag_error)
|
||||
-- warn
|
||||
local sign_diag_warn = { text = icons.warn, texthl = "DiagnosticSignWarn" }
|
||||
vim.fn.sign_define("DiagnosticSignWarn", sign_diag_warn)
|
||||
-- info
|
||||
local sign_diag_info = { text = icons.info, texthl = "DiagnosticSignInfo" }
|
||||
vim.fn.sign_define("DiagnosticSignInfo", sign_diag_info)
|
||||
-- hint
|
||||
local sign_diag_hint = { text = icons.hint, texthl = "DiagnosticSignHint" }
|
||||
vim.fn.sign_define("DiagnosticSignHint", sign_diag_hint)
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
M.sign_defines()
|
||||
end
|
||||
|
||||
return M
|
17
lua/util/lsp.lua
Normal file
17
lua/util/lsp.lua
Normal file
@ -0,0 +1,17 @@
|
||||
local M = {}
|
||||
|
||||
function M.setup_keys()
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function()
|
||||
local map = vim.keymap.set
|
||||
|
||||
map("n", "K", vim.lsp.buf.hover, { desc = "hover" })
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
M.setup_keys()
|
||||
end
|
||||
|
||||
return M
|
56
lua/util/path.lua
Normal file
56
lua/util/path.lua
Normal file
@ -0,0 +1,56 @@
|
||||
local M = {}
|
||||
|
||||
function M.sep()
|
||||
return vim.fn.has("win32") and "\\" or "/"
|
||||
end
|
||||
|
||||
function M.normalize(path)
|
||||
local parts = {}
|
||||
for part in path:gmatch("([^/\\\\]*)") do
|
||||
if part ~= "" then
|
||||
table.insert(parts, part)
|
||||
end
|
||||
end
|
||||
local path_joined = table.concat(parts, M.sep())
|
||||
|
||||
local first_char = path:sub(1, 1)
|
||||
if first_char == "/" or first_char == "\\" then
|
||||
path_joined = M.sep() .. path_joined
|
||||
end
|
||||
local last_char = path:sub(path:len())
|
||||
if last_char == "/" or last_char == "\\" then
|
||||
path_joined = path_joined .. M.sep()
|
||||
end
|
||||
return vim.fn.expand(path_joined)
|
||||
end
|
||||
|
||||
function M.join(base_path, ...)
|
||||
local parts = { base_path }
|
||||
for _, part in ipairs({ ... }) do
|
||||
table.insert(parts, part)
|
||||
end
|
||||
|
||||
local path_joined = table.concat(parts, M.sep())
|
||||
return M.normalize(path_joined)
|
||||
end
|
||||
|
||||
function M.join_stdpath(what, ...)
|
||||
local base_path = vim.fn.stdpath(what)
|
||||
local parts = { base_path }
|
||||
for _, part in ipairs({ ... }) do
|
||||
table.insert(parts, part)
|
||||
end
|
||||
|
||||
local path_joined = table.concat(parts, M.sep())
|
||||
return M.normalize(path_joined)
|
||||
end
|
||||
|
||||
function M.is_directory(path)
|
||||
return vim.fn.isdirectory(M.normalize(path)) == 1
|
||||
end
|
||||
|
||||
function M.is_file(path)
|
||||
return vim.fn.filereadable(M.normalize(path)) == 1
|
||||
end
|
||||
|
||||
return M
|
Reference in New Issue
Block a user