mirror of
https://github.com/dcarrillo/dotfiles.git
synced 2025-07-01 23:19:25 +00:00
[neovim] Move utils to a external file
This commit is contained in:
@ -19,34 +19,6 @@ local lazy_opts = {
|
||||
},
|
||||
}
|
||||
|
||||
local uv = vim.loop
|
||||
local function readFile(path)
|
||||
local fd = uv.fs_open(path, "r", 438)
|
||||
if fd == nil then
|
||||
return nil
|
||||
end
|
||||
local stat = uv.fs_fstat(fd)
|
||||
if fd == nil then
|
||||
return nil
|
||||
end
|
||||
local data = uv.fs_read(fd, stat.size, 0)
|
||||
if data == nil then
|
||||
return nil
|
||||
end
|
||||
assert(uv.fs_close(fd))
|
||||
|
||||
return data
|
||||
end
|
||||
|
||||
local projects = function()
|
||||
local data = readFile(os.getenv("HOME") .. "/.config/nvim/neovim-projects.json")
|
||||
if data then
|
||||
return vim.json.decode(data)
|
||||
else
|
||||
return {}
|
||||
end
|
||||
end
|
||||
|
||||
require("lazy").setup({
|
||||
-- Colorschemes
|
||||
{
|
||||
@ -111,7 +83,7 @@ require("lazy").setup({
|
||||
{ "nvim-lua/plenary.nvim", lazy = true },
|
||||
{ "echasnovski/mini.starter", lazy = "VimEnter", version = "*" },
|
||||
{ "windwp/nvim-autopairs" },
|
||||
{ "numToStr/Comment.nvim", version = "v0.*" },
|
||||
{ "numToStr/Comment.nvim" },
|
||||
{ "JoosepAlviste/nvim-ts-context-commentstring" },
|
||||
{ "nvim-tree/nvim-web-devicons", lazy = true },
|
||||
{ "akinsho/bufferline.nvim", event = "VeryLazy", version = "v4.*" },
|
||||
@ -130,14 +102,6 @@ require("lazy").setup({
|
||||
{ "mg979/vim-visual-multi" },
|
||||
{
|
||||
"coffebar/neovim-project",
|
||||
opts = {
|
||||
projects = projects(),
|
||||
last_session_on_startup = false,
|
||||
filetype_autocmd_timeout = 0,
|
||||
},
|
||||
init = function()
|
||||
vim.opt.sessionoptions:append("globals")
|
||||
end,
|
||||
dependencies = {
|
||||
{ "Shatur/neovim-session-manager" },
|
||||
},
|
||||
@ -154,7 +118,6 @@ require("lazy").setup({
|
||||
{ "tenxsoydev/karen-yank.nvim", event = "VeryLazy", config = true },
|
||||
{
|
||||
"ggandor/leap.nvim",
|
||||
version = "*",
|
||||
config = function()
|
||||
require("leap").add_default_mappings()
|
||||
vim.api.nvim_set_hl(0, "LeapBackdrop", { link = "Comment" })
|
||||
@ -162,7 +125,6 @@ require("lazy").setup({
|
||||
},
|
||||
{
|
||||
"knubie/vim-kitty-navigator",
|
||||
version = "*",
|
||||
build = "cp ./*.py ~/.config/kitty/",
|
||||
},
|
||||
{
|
||||
|
@ -24,3 +24,4 @@ require("plugins.ufo")
|
||||
require("plugins.bufferline")
|
||||
require("plugins.lualine")
|
||||
require("plugins.grug-far")
|
||||
require("plugins.neovim-project")
|
||||
|
19
.config/nvim/lua/plugins/neovim-project.lua
Normal file
19
.config/nvim/lua/plugins/neovim-project.lua
Normal file
@ -0,0 +1,19 @@
|
||||
local projects = function()
|
||||
local data = require("util.files").read(os.getenv("HOME") .. "/.config/nvim/neovim-projects.json")
|
||||
if data then
|
||||
return vim.json.decode(data)
|
||||
else
|
||||
return {}
|
||||
end
|
||||
end
|
||||
|
||||
require("neovim-project").setup({
|
||||
projects = projects(),
|
||||
last_session_on_startup = false,
|
||||
dashboard_mode = true,
|
||||
filetype_autocmd_timeout = 0,
|
||||
autosave_ignore_filetypes = {
|
||||
"neo-tree",
|
||||
"trouble",
|
||||
},
|
||||
})
|
10
.config/nvim/lua/util/files.lua
Normal file
10
.config/nvim/lua/util/files.lua
Normal file
@ -0,0 +1,10 @@
|
||||
local M = {}
|
||||
|
||||
M.read = function(file)
|
||||
local fd = assert(io.open(file, "r"))
|
||||
local data = fd:read("*a")
|
||||
fd:close()
|
||||
return data
|
||||
end
|
||||
|
||||
return M
|
Reference in New Issue
Block a user