jsonpath.nvim
jsonpath.nvim copied to clipboard
Support for different types than .json
How can I use this inside files with other extensions? Do I need to set up lsp correctly to support more than one filetype?
As long as the file uses Treesitter JSON parser, it should work regardless of the filetype.
For example, if you want to support jsonc
(JSON with comments) file types, paste the following in after/ftplugin/jsonc.lua
:
-- show json path in the winbar
if vim.fn.exists("+winbar") == 1 then
vim.opt_local.winbar = "%{%v:lua.require'jsonpath'.get()%}"
end
The plugin does not depend on any LSP functionality, only Treesitter.
Can I get this to work with javascript objects? i.e. get the path of an arbitrary nested field of an arbitrary object inside a javascript file that will most probably have other content around it as well?