aboutsummaryrefslogtreecommitdiffstats
path: root/lua/config
diff options
context:
space:
mode:
Diffstat (limited to 'lua/config')
-rw-r--r--lua/config/autocmds.lua55
-rw-r--r--lua/config/composer.lua104
-rw-r--r--lua/config/init.lua1
-rw-r--r--lua/config/lazy.lua6
4 files changed, 150 insertions, 16 deletions
diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua
index 86d3e1d..24ff236 100644
--- a/lua/config/autocmds.lua
+++ b/lua/config/autocmds.lua
@@ -38,17 +38,6 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
end,
})
-if vim.fn.has "persistent_undo" then
- local target_path = vim.fn.expand "~/.cache/undodir"
- -- crear el directorio y cualquier directorio padre
- -- si la ubicación no existe.
- if not vim.fn.isdirectory(target_path) then
- vim.fn.mkdir(target_path, "p", 0700)
- end
-
- vim.o.undodir = target_path
- vim.o.undofile = true
-end
-- Función para alternar el ajuste de línea
function ToggleWrap()
local wrap = vim.wo.wrap
@@ -84,3 +73,47 @@ vim.api.nvim_create_autocmd("BufEnter", {
end
end,
})
+
+-- Autocmds are automatically loaded on the VeryLazy event
+-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
+-- Add any additional autocmds here
+--
+local function augroup(name)
+ return vim.api.nvim_create_augroup("my_lazyvim_" .. name, { clear = true })
+end
+
+-- Set filetype for .env and .env.* files
+vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
+ group = augroup("env_filetype"),
+ pattern = { "*.env", ".env.*" },
+ callback = function()
+ vim.opt_local.filetype = "sh"
+ end,
+})
+
+-- Set filetype for .hurl files
+vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
+ group = augroup("hurl_filetype"),
+ pattern = { "*.hurl" },
+ callback = function()
+ vim.opt_local.filetype = "hurl"
+ end,
+})
+
+-- Set filetype for .toml files
+vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
+ group = augroup("toml_filetype"),
+ pattern = { "*.tomg-config*" },
+ callback = function()
+ vim.opt_local.filetype = "toml"
+ end,
+})
+
+-- Set filetype for .ejs files
+vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
+ group = augroup("ejs_filetype"),
+ pattern = { "*.ejs", "*.ejs.t" },
+ callback = function()
+ vim.opt_local.filetype = "embedded_template"
+ end,
+})
diff --git a/lua/config/composer.lua b/lua/config/composer.lua
new file mode 100644
index 0000000..2405416
--- /dev/null
+++ b/lua/config/composer.lua
@@ -0,0 +1,104 @@
+vim.treesitter.query.set(
+ "json",
+ "composer_dependencies",
+ [[
+ (pair
+ key: (string
+ (string_content) @key (#match? @key "require|require-dev")
+ )
+ value: (object
+ (pair
+ key: (string (string_content) @depen)
+ )
+ )
+ )
+ ]]
+)
+local group = vim.api.nvim_create_augroup("composer-info", {})
+vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost" }, {
+ pattern = "composer.json",
+ group = group,
+ callback = function(event)
+ local parser = vim.treesitter.get_parser(event.buf, "json")
+ local tree = parser:parse()[1]
+ if tree == nil then
+ return
+ end
+ local query = vim.treesitter.query.get("json", "composer_dependencies")
+ if not query then
+ return
+ end
+
+ local dependencies = {}
+
+ for id, node in query:iter_captures(tree:root(), event.buf) do
+ if query.captures[id] == "depen" then
+ table.insert(dependencies, {
+ name = vim.treesitter.get_node_text(node, event.buf),
+ line = node:start(),
+ })
+ end
+ end
+
+ if #dependencies == 0 then
+ return
+ end
+
+ local ns = vim.api.nvim_create_namespace("composer-deps")
+ vim.api.nvim_buf_clear_namespace(event.buf, ns, 0, -1)
+
+ vim.system(
+ { "composer", "info", "-f", "json" },
+ {},
+ vim.schedule_wrap(function(out)
+ if out.code ~= 0 then
+ return
+ end
+
+ local data = vim.json.decode(out.stdout, {})
+ if type(data.installed) ~= "table" then
+ return
+ end
+
+ for _, dep in ipairs(dependencies) do
+ local info = vim.iter(data.installed):find(function(inst)
+ return dep.name == inst.name
+ end)
+ if info then
+ vim.api.nvim_buf_set_extmark(event.buf, ns, dep.line, 0, {
+ virt_text = { { string.format('<- %s', info.version), "comment" } },
+ virt_text_pos = "eol",
+ })
+ end
+ end
+ end)
+ )
+ vim.system(
+ { "composer", "outdated", "-f", "json" },
+ {},
+ vim.schedule_wrap(function(out)
+ if out.code ~= 0 then
+ return
+ end
+
+ local data = vim.json.decode(out.stdout, {})
+ if type(data.installed) ~= "table" then
+ return
+ end
+
+ for _, dep in ipairs(dependencies) do
+ local info = vim.iter(data.installed):find(function(inst)
+ return dep.name == inst.name
+ end)
+ if info then
+ vim.api.nvim_buf_set_extmark(event.buf, ns, dep.line - 1, 0, {
+ virt_text = { { string.format('^ %s (new version)', info.latest), "error" } },
+ virt_text_pos = "eol",
+ })
+ end
+ end
+ end)
+ )
+ end,
+})
+
diff --git a/lua/config/init.lua b/lua/config/init.lua
index 008ebf5..74e9c00 100644
--- a/lua/config/init.lua
+++ b/lua/config/init.lua
@@ -8,6 +8,7 @@ vim.api.nvim_create_autocmd("User", {
require "config.usercmds"
require "config.keymaps"
require "config.diagnostic"
+ require "config.composer"
end,
})
require "config.lazy"
diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua
index 70aaec7..34e034f 100644
--- a/lua/config/lazy.lua
+++ b/lua/config/lazy.lua
@@ -13,7 +13,7 @@ vim.opt.rtp:prepend(lazypath)
require("lazy").setup {
-- leave nil when passing the spec as the first argument to setup()
- spec = { { import = "plugins" } },
+ spec = { { "LazyVim/LazyVim", import = "plugins" } },
local_spec = true, -- load project specific .lazy.lua spec files. They will be added at the end of the spec.
defaults = {
-- Set this to `true` to have all your plugins lazy-loaded by default.
@@ -200,7 +200,3 @@ require("lazy").setup {
},
}
-
-
-
-