Compare commits
2 Commits
ab4f565cb5
...
36261800c0
Author | SHA1 | Date | |
---|---|---|---|
36261800c0 | |||
4ea16fa3f0 |
@ -35,6 +35,7 @@
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "0bb67ef952ea3eb7b1bac9c011281471d99a27bc" },
|
||||
"oil.nvim": { "branch": "master", "commit": "132b4ea0740c417b9d717411cab4cf187e1fd095" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" },
|
||||
"presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" },
|
||||
"promise-async": { "branch": "main", "commit": "94f6f03c6c1e2aab551aacdf0c1e597a7269abb6" },
|
||||
"rainbow_csv.nvim": { "branch": "main", "commit": "a520dabf1c74d7d7d8341dd3f3570063ef51b3aa" },
|
||||
"resession.nvim": { "branch": "master", "commit": "742aba4998123fc11f490a3aeffe8f550b2cb789" },
|
||||
|
@ -7,9 +7,21 @@ spec.dependencies = {
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"nvim-telescope/telescope.nvim",
|
||||
"folke/neodev.nvim",
|
||||
{ "folke/neoconf.nvim", tag = "v1.2.2" },
|
||||
}
|
||||
|
||||
spec.config = function()
|
||||
local neoconf = require("neoconf")
|
||||
|
||||
neoconf.setup({
|
||||
-- ignore foreign imports
|
||||
import = {
|
||||
vscode = false,
|
||||
coc = false,
|
||||
nlsp = false,
|
||||
}
|
||||
})
|
||||
|
||||
local mason = require("mason")
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
local spec = {
|
||||
"folke/neoconf.nvim",
|
||||
tag = "v1.2.2",
|
||||
}
|
||||
|
||||
spec.opts = {
|
||||
-- ignore foreign imports
|
||||
import = {
|
||||
vscode = false,
|
||||
coc = false,
|
||||
nlsp = false,
|
||||
}
|
||||
}
|
||||
|
||||
return spec
|
92
lua/valeth/plugins/presence.lua
Normal file
92
lua/valeth/plugins/presence.lua
Normal file
@ -0,0 +1,92 @@
|
||||
local create_autocmd = vim.api.nvim_create_autocmd
|
||||
local create_autogroup = vim.api.nvim_create_augroup
|
||||
local create_usercmd = vim.api.nvim_create_user_command
|
||||
|
||||
local presence_enabled = false
|
||||
|
||||
local function enabled_for_project()
|
||||
local neoconf = require("neoconf")
|
||||
return neoconf.get("presence") or false
|
||||
end
|
||||
|
||||
local function enable()
|
||||
local presence = require("presence")
|
||||
presence_enabled = true
|
||||
presence:handle_win_enter()
|
||||
end
|
||||
|
||||
local function disable()
|
||||
local presence = require("presence")
|
||||
presence_enabled = false
|
||||
presence:cancel()
|
||||
end
|
||||
|
||||
local function toggle()
|
||||
if presence_enabled then
|
||||
disable()
|
||||
else
|
||||
enable()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local spec = {
|
||||
"andweeb/presence.nvim",
|
||||
}
|
||||
|
||||
spec.dependencies = {
|
||||
"folke/neoconf.nvim",
|
||||
}
|
||||
|
||||
spec.config = function()
|
||||
local presence = require("presence")
|
||||
|
||||
local presence_group = create_autogroup("PresenceEvents", { clear = true })
|
||||
local presence_autocmds = {
|
||||
["FocusGained"] = "handle_focus_gained",
|
||||
["TextChanged"] = "handle_text_changed",
|
||||
["VimLeavePre"] = "handle_vim_leave_pre",
|
||||
["WinEnter"] = "handle_win_enter",
|
||||
["WinLeave"] = "handle_win_leave",
|
||||
["BufEnter"] = "handle_buf_enter",
|
||||
["BufAdd"] = "handle_buf_add",
|
||||
}
|
||||
|
||||
for event, callback_fn in pairs(presence_autocmds) do
|
||||
create_autocmd(event, {
|
||||
group = presence_group,
|
||||
callback = function()
|
||||
if presence_enabled then
|
||||
presence[callback_fn](presence)
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
create_autocmd({"VimEnter", "BufEnter"}, {
|
||||
group = presence_group,
|
||||
callback = function()
|
||||
if enabled_for_project() then
|
||||
enable()
|
||||
else
|
||||
disable()
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
create_usercmd("PresenceToggle", toggle, { nargs = 0 })
|
||||
|
||||
create_usercmd("PresenceState",
|
||||
function()
|
||||
print(presence_enabled and "enabled" or "disabled")
|
||||
end,
|
||||
{ nargs = 0 }
|
||||
)
|
||||
|
||||
presence.setup({
|
||||
auto_update = false,
|
||||
show_time = false,
|
||||
})
|
||||
end
|
||||
|
||||
return spec
|
Loading…
Reference in New Issue
Block a user