Skip to content

Commit

Permalink
Merge pull request #25 from joshzcold/main
Browse files Browse the repository at this point in the history
Add function to return the path, to be added to the winbar. Like jsonpath.nvim
  • Loading branch information
cuducos committed Oct 31, 2023
2 parents 400b2ed + 99243d2 commit b642efd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ Plug 'nvim-treesitter/nvim-treesitter'
Plug 'cuducos/yaml.nvim'
```

## Configuration

### Showing the YAML patch and value in Neovim's winbar

```lua
vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = { "yaml" },
callback = function()
vim.opt_local.winbar = [[%{%v:lua.require("yaml_nvim").get_yaml_key_and_value()%}]]
end,
})
```

## Reporting bugs and contributing

There is a mini toolchain to help you test the plugin in isolation using a container. It requires:
Expand Down
19 changes: 11 additions & 8 deletions lua/yaml_nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,18 @@ local yank = function(key, value, register)
end

M.view = function()
assure_yaml_filetype(function()
local node = document.get_key_relevant_to_cursor()
if node == nil then
return
end
vim.notify(M.get_yaml_key_and_value())
end

local parsed = pair.parse(node)
vim.notify(parsed.human)
end)
M.get_yaml_key_and_value = function()
local restore_to = set_yaml_as_filetype()
local node = document.get_key_relevant_to_cursor()
if node == nil then
return
end
local parsed = pair.parse(node)
restore_filetype(restore_to)
return parsed.human
end

M.yank = function(register)
Expand Down

0 comments on commit b642efd

Please sign in to comment.