Skip to content

Commit

Permalink
fix: minor linting and deprecation issues (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
Allaman authored Dec 16, 2023
1 parent 4eee754 commit bb0c5a6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lua/kustomize/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local function configure_buffer()
local win, buf = utils.create_output()
vim.api.nvim_win_set_buf(win, buf)
vim.api.nvim_buf_set_name(buf, "Kustomize #" .. buf)
vim.api.nvim_buf_set_option(buf, "filetype", "yaml")
vim.api.nvim_set_option_value("filetype", "yaml", { buf, buf })
utils.delete_output_keybinding(win, buf)
return buf
end
Expand Down Expand Up @@ -39,6 +39,9 @@ M.build = function()
end
local bufName = vim.api.nvim_buf_get_name(0)
local dirName = vim.fs.dirname(bufName)
if dirName == nil then
return
end
local err, manifest = M.kustomize_build(dirName)
-- https://stackoverflow.com/questions/1252539/most-efficient-way-to-determine-if-a-lua-table-is-empty-contains-no-entries
if next(err) ~= nil then
Expand Down
2 changes: 1 addition & 1 deletion lua/kustomize/deprecations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local M = {}
---run 'kubent' command on the input file
---@param config table
---@param input string
---@return table
---@return table, table
M.run_deprecations_check = function(config, input)
local kube_version = config.options.deprecations.kube_version
local Job = require("plenary.job")
Expand Down
6 changes: 4 additions & 2 deletions lua/kustomize/resources.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function M.find_resources(bufNr)
)
---@type table<string>
local resources = {}
for _, captures, _ in query:iter_matches(root, bufNr) do
for _, captures, _ in query:iter_matches(root, bufNr, 0, 0, {}) do
-- resource is second capture
table.insert(resources, t.get_node_text(captures[2], bufNr))
end
Expand All @@ -44,7 +44,9 @@ M.list = function()
local bufName = vim.api.nvim_buf_get_name(0)
local bufNr = vim.api.nvim_win_get_buf(0)
local fileName = vim.fs.basename(bufName)

if fileName == nil then
return
end
if not utils.is_kustomization_yaml(fileName) then
utils.error("buffer is not a kustomization.y(a)ml")
return
Expand Down
2 changes: 1 addition & 1 deletion lua/kustomize/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ end
---@param win integer
---@param buf integer
M.delete_output = function(win, buf)
vim.api.nvim_win_close(win, "force")
vim.api.nvim_win_close(win, true)
vim.api.nvim_buf_delete(buf, { force = true })
end

Expand Down

0 comments on commit bb0c5a6

Please sign in to comment.