{"id":17006072,"url":"https://github.com/duologic/nvim-jsonnet","last_synced_at":"2025-04-12T06:31:40.347Z","repository":{"id":183296305,"uuid":"669878322","full_name":"Duologic/nvim-jsonnet","owner":"Duologic","description":"Neovim plugin for Jsonnet (in Lua)","archived":false,"fork":false,"pushed_at":"2024-06-13T07:49:13.000Z","size":17,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T01:51:14.306Z","etag":null,"topics":["jsonnet","nvim","nvim-plugin","tree-sitter-highlight"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Duologic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-23T18:11:44.000Z","updated_at":"2024-11-25T14:07:17.000Z","dependencies_parsed_at":"2024-06-13T10:24:25.480Z","dependency_job_id":null,"html_url":"https://github.com/Duologic/nvim-jsonnet","commit_stats":null,"previous_names":["duologic/nvim-jsonnet"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Duologic%2Fnvim-jsonnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Duologic%2Fnvim-jsonnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Duologic%2Fnvim-jsonnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Duologic%2Fnvim-jsonnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Duologic","download_url":"https://codeload.github.com/Duologic/nvim-jsonnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248529650,"owners_count":21119547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jsonnet","nvim","nvim-plugin","tree-sitter-highlight"],"created_at":"2024-10-14T05:04:56.981Z","updated_at":"2025-04-12T06:31:35.315Z","avatar_url":"https://github.com/Duologic.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nvim-jsonnet\n\nFeatures:\n* Provide functions to evaluate Jsonnet code inside a split view\n* Extend nvim-treesitter highlighting with references and linting\n\n## Usage\n\n```lua\nrequire('nvim-jsonnet').setup({\n    -- Opinionated defaults\n    jsonnet_bin = 'jsonnet',\n    jsonnet_args = { '-J', 'vendor', '-J', 'lib' },\n    jsonnet_string_bin = 'jsonnet',\n    jsonnet_string_args = { '-S', '-J', 'vendor', '-J', 'lib' },\n    use_tanka_if_possible = true\n\n    -- default to false to not break existing installs\n    load_lsp_config = false\n    -- Pass along nvim-cmp capabilities if you use that.\n    capabilities = require('cmp_nvim_lsp').default_capabilities(),\n\n    -- default to false to not break existing installs\n    load_dap_config = false,\n    jsonnet_debugger_bin = 'jsonnet-debugger',\n    jsonnet_debugger_args = { '-s', '-d', '-J', 'vendor', '-J', 'lib' },\n})\n```\n\nIf the environment variable `JSONNET_BIN` is set, it will use that instead of the configured values. This allows us to override the binary at a project level.\n\nWhen `use_tanka_if_possible`, it will check whether Tanka can resolve the JPATH and attempt to use `tk eval` instead of configured values.\n\nBy default, `:JsonnetEval` will open in a horizontal split, use `:vertical JsonnetEval` to launch the split vertically.\n\n## Differences from vim-jsonnet\n\nThis plugin does not provide syntax highlighting, folding, formatting or linting. Please rely on LSP, Treesitter and other plugins to aid with this.\n\n### LSP Config\n\nLSP with jsonnet-language-server provides formatting and linting out of the box, this config uses [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig/).\n\nSee [Usage](#Usage) to enable opinionated setup.\n\nTip: configure format on save for all LSP buffers:\n```lua\n-- Format on save\nvim.api.nvim_create_autocmd(\n    'BufWritePre',\n    {\n        buffer = buffer,\n        callback = function()\n            vim.lsp.buf.format { async = false }\n        end\n    }\n)\n```\n\n### DAP\n\n[nvim-dap](https://github.com/mfussenegger/nvim-dap) provides a way to run the [jsonnet-debugger](https://github.com/grafana/jsonnet-debugger), this works great in combination with [nvim-dap-ui](https://github.com/rcarriga/nvim-dap-ui).\n\nInstall the debugger with `go install github.com/grafana/jsonnet-debugger@v0.1.0` and see [Usage](#Usage) to enable.\n\n### Treesitter\n\nTreesitter provides better highlighting and folding capabilities, this config uses [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).\n\nMinimal configuration:\n\n```lua\nrequire 'nvim-treesitter'.setup()\nrequire 'nvim-treesitter.configs'.setup({\n    highlight = { enable = true },\n})\n\nvim.wo.foldmethod = 'expr'\nvim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'\nvim.wo.foldlevel  = 1000\n```\n\n### null-ls/cbfmt\n\nFor formatting code blocks inside Markdown you can use null-ls with `cbfmt`.\n\nTODO: null-ls has been archived, look for replacement.\n\n```lua\nlocal null_ls = require('null-ls')\n\nlocal function getFileType()\n    local ft = vim.bo.filetype\n    for index, value in ipairs({ 'markdown', 'org', 'restructuredtext' }) do\n        if value == ft then\n            return ft\n        end\n    end\n    return 'markdown' -- fallback\nend\n\nnull_ls.setup({\n    sources = {\n        null_ls.builtins.formatting.cbfmt.with({\n            filetypes = { 'markdown', 'org', 'restructuredtext' },\n            extra_args = {\n                '--config', vim.fn.expand('~/.config/nvim/cbfmt.toml'),\n                '--parser', getFileType(),\n            }\n        }),\n    },\n})\n```\n\n```toml\n# ~/.config/nvim/cbfmt.toml\n[languages]\njsonnet = [\"jsonnetfmt --no-use-implicit-plus -\"]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduologic%2Fnvim-jsonnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduologic%2Fnvim-jsonnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduologic%2Fnvim-jsonnet/lists"}