jsonpath.nvim icon indicating copy to clipboard operation
jsonpath.nvim copied to clipboard

Support for different types than .json

Open k4-100 opened this issue 1 year ago • 2 comments

How can I use this inside files with other extensions? Do I need to set up lsp correctly to support more than one filetype?

k4-100 avatar Jul 11 '23 17:07 k4-100

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.

phelipetls avatar Jul 11 '23 18:07 phelipetls

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?

ic-768 avatar Jul 22 '24 11:07 ic-768