diff --git a/lua/crentist/lazy/fugitive.lua b/lua/crentist/lazy/fugitive.lua index 7b7e754..e34bf22 100644 --- a/lua/crentist/lazy/fugitive.lua +++ b/lua/crentist/lazy/fugitive.lua @@ -1,34 +1,35 @@ return { - "tpope/vim-fugitive", - config = function() - vim.keymap.set("n", "gs", vim.cmd.Git) + 'tpope/vim-fugitive', + config = function() + vim.keymap.set('n', "gs", vim.cmd.Git) - local Crentist_Fugitive = vim.api.nvim_create_augroup("Crentist_Fugitive", {}) + local Crentist_Fugitive = vim.api.nvim_create_augroup('Crentist_Fugitive', {}) local autocmd = vim.api.nvim_create_autocmd - autocmd("BufWinEnter", { + autocmd('BufWinEnter', { group = Crentist_Fugitive, - pattern = "*", + pattern = '*', callback = function() - if vim.bo.ft ~= "fugitive" then + if vim.bo.ft ~= 'fugitive' then return end local bufnr = vim.api.nvim_get_current_buf() local opts = {buffer = bufnr, remap = false} - vim.keymap.set("n", "p", function() + vim.keymap.set('n', "p", function() vim.cmd.Git('push') end, opts) -- rebase always - vim.keymap.set("n", "P", function() + vim.keymap.set('n', "P", function() vim.cmd.Git({'pull', '--rebase'}) end, opts) -- NOTE: It allows me to easily set the branch i am pushing and any tracking -- needed if i did not set the branch up correctly - vim.keymap.set("n", "t", ":Git push -u origin ", opts); + vim.keymap.set('n', "t", ":Git push -u origin ", opts); end, }) end } + diff --git a/lua/crentist/lazy/gitsigns.lua b/lua/crentist/lazy/gitsigns.lua index b6c7a27..b3b06a6 100644 --- a/lua/crentist/lazy/gitsigns.lua +++ b/lua/crentist/lazy/gitsigns.lua @@ -1,5 +1,5 @@ return { - "lewis6991/gitsigns.nvim", + 'lewis6991/gitsigns.nvim', opts = { current_line_blame = true, attach_to_untracked = true, diff --git a/lua/crentist/lazy/harpoon.lua b/lua/crentist/lazy/harpoon.lua index 0d8449e..c6cfa47 100644 --- a/lua/crentist/lazy/harpoon.lua +++ b/lua/crentist/lazy/harpoon.lua @@ -1,14 +1,14 @@ return { - "theprimeagen/harpoon", - branch = "harpoon2", - dependencies = { "nvim-lua/plenary.nvim" }, + 'theprimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'nvim-lua/plenary.nvim' }, config = function() - local harpoon = require("harpoon") + local harpoon = require('harpoon') harpoon:setup() -- basic telescope configuration - local conf = require("telescope.config").values + local conf = require('telescope.config').values local function toggle_telescope(harpoon_files) local file_paths = {} for _, item in ipairs(harpoon_files.items) do @@ -16,8 +16,8 @@ return { end require('telescope.pickers').new({}, { - prompt_title = "Harpoon", - finder = require("telescope.finders").new_table({ + prompt_title = 'Harpoon', + finder = require('telescope.finders').new_table({ results = file_paths, }), previewer = conf.file_previewer({}), @@ -25,15 +25,15 @@ return { }):find() end - vim.keymap.set("n", "a", function() harpoon:list():add() end) - vim.keymap.set("n", "", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) - vim.keymap.set("n", "", function() toggle_telescope(harpoon:list()) end, - { desc = "Open harpoon window" }) + vim.keymap.set('n', 'a', function() harpoon:list():add() end) + vim.keymap.set('n', '', function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) + vim.keymap.set('n', '', function() toggle_telescope(harpoon:list()) end, + { desc = 'Open harpoon window' }) - vim.keymap.set("n", "", function() harpoon:list():select(1) end) - vim.keymap.set("n", "", function() harpoon:list():select(2) end) - vim.keymap.set("n", "", function() harpoon:list():select(3) end) - vim.keymap.set("n", "", function() harpoon:list():select(4) end) + vim.keymap.set('n', '', function() harpoon:list():select(1) end) + vim.keymap.set('n', '', function() harpoon:list():select(2) end) + vim.keymap.set('n', '', function() harpoon:list():select(3) end) + vim.keymap.set('n', '', function() harpoon:list():select(4) end) end } diff --git a/lua/crentist/lazy/indent-blanklines.lua b/lua/crentist/lazy/indent-blanklines.lua index ef71fa4..faf7a21 100644 --- a/lua/crentist/lazy/indent-blanklines.lua +++ b/lua/crentist/lazy/indent-blanklines.lua @@ -1 +1,2 @@ -return { "lukas-reineke/indent-blankline.nvim", main = "ibl", opts = {} } +return { 'lukas-reineke/indent-blankline.nvim', main = 'ibl', opts = {} } + diff --git a/lua/crentist/lazy/init.lua b/lua/crentist/lazy/init.lua index b3f695d..32a2d4e 100644 --- a/lua/crentist/lazy/init.lua +++ b/lua/crentist/lazy/init.lua @@ -1,6 +1,7 @@ return { { - "nvim-lua/plenary.nvim", - name = "plenary" + 'nvim-lua/plenary.nvim', + name = 'plenary' }, } + diff --git a/lua/crentist/lazy/navic.lua b/lua/crentist/lazy/navic.lua index 39710fa..16c0f77 100644 --- a/lua/crentist/lazy/navic.lua +++ b/lua/crentist/lazy/navic.lua @@ -7,7 +7,8 @@ return { local navic = require('nvim-navic') navic.setup({ lsp = { - auto_attach = true + auto_attach = true, + preference = { 'helm_ls', 'yamlls' } } }) end diff --git a/lua/crentist/null-ls.lua b/lua/crentist/null-ls.lua index b3f322b..80d3603 100644 --- a/lua/crentist/null-ls.lua +++ b/lua/crentist/null-ls.lua @@ -1,3 +1,56 @@ --- https://www.youtube.com/watch?v=q-oBU2fO1H4&t=189s -local null_ls = require("null-ls") +local null_ls = require('null-ls') +local plenary = require('plenary') + +local kustomize_condition = function(node, params) + if node == nil then return false end + + if vim.treesitter.get_node_text(node, params['bufnr']) ~= 'resources' then return false end + + return true +end + +---@module 'null-ls' +---@type +local kustomize_action = { + method = null_ls.methods.CODE_ACTION, + filetypes = { 'yaml' }, + generator = { + fn = function(params) + local out = {} + local node = vim.treesitter.get_node() + if kustomize_condition(node, params) then + table.insert(out, { + title = '📁 Create resources', + action = function() + local node_below = vim.treesitter.get_node({ bufnr = 0, pos = { params['row'] + 1, 0 } }) + + if node_below == nil or node_below:type() ~= 'block_sequence' then + vim.api.nvim_echo({ { '❌Failed to get list items.', 'Normal' } }, false, {}) + return + end + + local checked_files = '' + for list_item, _ in node_below:iter_children() do + if list_item ~= nil then + local item_value_node = list_item:child(1) -- 0 is `-`, 1 is the actual value + if item_value_node ~= nil then + local file_name = vim.treesitter.get_node_text(item_value_node, params['bufnr']) + local file_name_path = plenary.path.new(file_name) + local current_file = plenary.path.new(vim.fn.expand('%')) + local parent = plenary.path.new(current_file:parents()[1]) + local new_file = parent / file_name + new_file:touch({mode=644}) + end + end + end + end, + }) + end + return out + end, + }, +} + +-- null_ls.deregister(kustomize_action) +null_ls.register(kustomize_action)