mirror of
https://github.com/Ascyii/nvim.git
synced 2026-01-01 04:04:24 -05:00
auto up 11:52:14 up 0:59, 2 users, load average: 0.27, 0.30, 0.33
This commit is contained in:
@@ -34,14 +34,8 @@ return {
|
|||||||
{
|
{
|
||||||
"<leader>g",
|
"<leader>g",
|
||||||
function()
|
function()
|
||||||
require('telescope.builtin').live_grep({
|
require('utils.functions').fzf_wrapped("grep")
|
||||||
disable_devicons = true,
|
end
|
||||||
cwd = vim.fn.getcwd(),
|
|
||||||
additional_args = function()
|
|
||||||
return { '--hidden', '--glob', '!.git/*' }
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"<leader>fh",
|
"<leader>fh",
|
||||||
@@ -52,20 +46,8 @@ return {
|
|||||||
{
|
{
|
||||||
"<leader><leader>",
|
"<leader><leader>",
|
||||||
function()
|
function()
|
||||||
require('telescope.builtin').find_files({
|
require('utils.functions').fzf_wrapped("find")
|
||||||
hidden = true,
|
end
|
||||||
no_ignore = true,
|
|
||||||
follow = true,
|
|
||||||
disable_devicons = false,
|
|
||||||
prompt_title = "Find Files",
|
|
||||||
find_command = {
|
|
||||||
"rg", "--files",
|
|
||||||
"--glob", "!**/.git/*",
|
|
||||||
"--glob", "!**/build/*",
|
|
||||||
"--glob", "!**/*.{jpg,png,gif,mp4,mkv,tar,zip,iso}"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
config = true,
|
config = true,
|
||||||
|
|||||||
@@ -2,109 +2,137 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.sleep(n)
|
function M.sleep(n)
|
||||||
os.execute("sleep " .. tonumber(n))
|
os.execute("sleep " .. tonumber(n))
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @return string
|
--- @return string
|
||||||
function M.get_cwd()
|
function M.get_cwd()
|
||||||
local cwd = vim.fn.getcwd()
|
local cwd = vim.fn.getcwd()
|
||||||
local home = os.getenv("HOME")
|
local home = os.getenv("HOME")
|
||||||
|
|
||||||
if cwd:sub(1, #home) == home then
|
if cwd:sub(1, #home) == home then
|
||||||
return "~" .. cwd:sub(#home + 1)
|
return "~" .. cwd:sub(#home + 1)
|
||||||
else
|
else
|
||||||
return cwd
|
return cwd
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.fzf_wrapped(type)
|
||||||
|
local t = require("telescope.builtin")
|
||||||
|
|
||||||
|
if type == "grep" then
|
||||||
|
t.live_grep({
|
||||||
|
disable_devicons = true,
|
||||||
|
cwd = vim.fn.getcwd(),
|
||||||
|
additional_args = function()
|
||||||
|
return { '--hidden', '--glob', '!.git/*' }
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
if type == "find" then
|
||||||
|
t.find_files({
|
||||||
|
hidden = true,
|
||||||
|
no_ignore = true,
|
||||||
|
follow = true,
|
||||||
|
disable_devicons = false,
|
||||||
|
prompt_title = "Find Files",
|
||||||
|
find_command = {
|
||||||
|
"rg", "--files",
|
||||||
|
"--glob", "!**/.git/*",
|
||||||
|
"--glob", "!**/build/*",
|
||||||
|
"--glob", "!**/*.{jpg,png,gif,mp4,mkv,tar,zip,iso}"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @return {}
|
--- @return {}
|
||||||
function M.get_lsp_servers()
|
function M.get_lsp_servers()
|
||||||
local servers = { "lua_ls" }
|
local servers = { "lua_ls" }
|
||||||
|
|
||||||
-- persistent state file
|
-- persistent state file
|
||||||
local state_file = vim.fn.stdpath("state") .. "/mason_skipped_jonas.json"
|
local state_file = vim.fn.stdpath("state") .. "/mason_skipped_jonas.json"
|
||||||
|
|
||||||
-- load previous warnings
|
-- load previous warnings
|
||||||
local warned = {}
|
local warned = {}
|
||||||
local ok, data = pcall(vim.fn.readfile, state_file)
|
local ok, data = pcall(vim.fn.readfile, state_file)
|
||||||
if ok and #data > 0 then
|
if ok and #data > 0 then
|
||||||
local decoded = vim.fn.json_decode(data)
|
local decoded = vim.fn.json_decode(data)
|
||||||
if decoded then warned = decoded end
|
if decoded then warned = decoded end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function save_state()
|
local function save_state()
|
||||||
vim.fn.writefile({ vim.fn.json_encode(warned) }, state_file)
|
vim.fn.writefile({ vim.fn.json_encode(warned) }, state_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function warn_once(key, msg)
|
local function warn_once(key, msg)
|
||||||
if not warned[key] then
|
if not warned[key] then
|
||||||
vim.notify(msg, vim.log.levels.WARN)
|
vim.notify(msg, vim.log.levels.WARN)
|
||||||
warned[key] = true
|
warned[key] = true
|
||||||
save_state()
|
save_state()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function populate_servers()
|
local function populate_servers()
|
||||||
if vim.fn.executable("go") == 1 then
|
if vim.fn.executable("go") == 1 then
|
||||||
table.insert(servers, "gopls")
|
table.insert(servers, "gopls")
|
||||||
else
|
else
|
||||||
warn_once("gopls", "[mason] Skipping gopls (go not found)")
|
warn_once("gopls", "[mason] Skipping gopls (go not found)")
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.fn.executable("php") == 1 then
|
if vim.fn.executable("php") == 1 then
|
||||||
table.insert(servers, "intelephense")
|
table.insert(servers, "intelephense")
|
||||||
else
|
else
|
||||||
warn_once("php", "[mason] Skipping intelephense (php not found)")
|
warn_once("php", "[mason] Skipping intelephense (php not found)")
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.fn.executable("hls") == 1 then
|
if vim.fn.executable("hls") == 1 then
|
||||||
table.insert(servers, "hls")
|
table.insert(servers, "hls")
|
||||||
else
|
else
|
||||||
warn_once("haskell", "[mason] Skipping hls (hls not found)")
|
warn_once("haskell", "[mason] Skipping hls (hls not found)")
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.fn.executable("npm") == 1 then
|
if vim.fn.executable("npm") == 1 then
|
||||||
if vim.fn.executable("clangd") == 1 then
|
if vim.fn.executable("clangd") == 1 then
|
||||||
table.insert(servers, "clangd")
|
table.insert(servers, "clangd")
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.fn.executable("java") == 1 then
|
if vim.fn.executable("java") == 1 then
|
||||||
table.insert(servers, "jdtls")
|
table.insert(servers, "jdtls")
|
||||||
end
|
end
|
||||||
table.insert(servers, "pyright")
|
table.insert(servers, "pyright")
|
||||||
table.insert(servers, "bashls")
|
table.insert(servers, "bashls")
|
||||||
table.insert(servers, "cssls")
|
table.insert(servers, "cssls")
|
||||||
table.insert(servers, "html")
|
table.insert(servers, "html")
|
||||||
table.insert(servers, "jsonls")
|
table.insert(servers, "jsonls")
|
||||||
else
|
else
|
||||||
warn_once("npm", "[mason] Skipping npm related (npm not found)")
|
warn_once("npm", "[mason] Skipping npm related (npm not found)")
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.fn.executable("cargo") == 1 then
|
if vim.fn.executable("cargo") == 1 then
|
||||||
if vim.fn.executable("nix") == 1 then
|
if vim.fn.executable("nix") == 1 then
|
||||||
table.insert(servers, "nil_ls")
|
table.insert(servers, "nil_ls")
|
||||||
else
|
else
|
||||||
warn_once("nix", "[mason] Skipping nil_ls and nixfmt (nix not found)")
|
warn_once("nix", "[mason] Skipping nil_ls and nixfmt (nix not found)")
|
||||||
end
|
end
|
||||||
table.insert(servers, "rust_analyzer")
|
table.insert(servers, "rust_analyzer")
|
||||||
else
|
else
|
||||||
warn_once("cargo", "[mason] Skipping nil_ls/rust_analyzer (cargo not found)")
|
warn_once("cargo", "[mason] Skipping nil_ls/rust_analyzer (cargo not found)")
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.fn.executable("deno") == 1 then
|
if vim.fn.executable("deno") == 1 then
|
||||||
table.insert(servers, "ts_ls")
|
table.insert(servers, "ts_ls")
|
||||||
else
|
else
|
||||||
warn_once("deno", "[mason] Skipping denols and tsserver (deno not found)")
|
warn_once("deno", "[mason] Skipping denols and tsserver (deno not found)")
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.fn.executable("zls") == 1 then
|
if vim.fn.executable("zls") == 1 then
|
||||||
table.insert(servers, "zls")
|
table.insert(servers, "zls")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
populate_servers()
|
||||||
|
return servers
|
||||||
populate_servers()
|
|
||||||
return servers
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Reference in New Issue
Block a user