{"id":13495929,"url":"https://github.com/SmiteshP/nvim-gps","last_synced_at":"2025-03-28T17:34:17.894Z","repository":{"id":37596261,"uuid":"398757196","full_name":"SmiteshP/nvim-gps","owner":"SmiteshP","description":"Simple statusline component that shows what scope you are working inside","archived":true,"fork":false,"pushed_at":"2022-07-05T03:25:02.000Z","size":150,"stargazers_count":477,"open_issues_count":6,"forks_count":47,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-31T11:36:42.152Z","etag":null,"topics":["lua","neovim","neovim-plugin","nvim","nvim-plugin","nvim-treesitter","treesitter"],"latest_commit_sha":null,"homepage":"","language":"Scheme","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SmiteshP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"SmiteshP"}},"created_at":"2021-08-22T09:05:55.000Z","updated_at":"2024-10-11T13:21:36.000Z","dependencies_parsed_at":"2022-07-31T23:48:15.784Z","dependency_job_id":null,"html_url":"https://github.com/SmiteshP/nvim-gps","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmiteshP%2Fnvim-gps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmiteshP%2Fnvim-gps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmiteshP%2Fnvim-gps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SmiteshP%2Fnvim-gps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SmiteshP","download_url":"https://codeload.github.com/SmiteshP/nvim-gps/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246069721,"owners_count":20718778,"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":["lua","neovim","neovim-plugin","nvim","nvim-plugin","nvim-treesitter","treesitter"],"created_at":"2024-07-31T19:01:39.834Z","updated_at":"2025-03-28T17:34:17.604Z","avatar_url":"https://github.com/SmiteshP.png","language":"Scheme","funding_links":["https://github.com/sponsors/SmiteshP"],"categories":["Scheme"],"sub_categories":[],"readme":"# ⚠️ Deprecated! Use [nvim-navic](https://github.com/SmiteshP/nvim-navic) instead of this plugin\n\nnvim-navic is an improved version of nvim-gps (a version 2.0!). It accompishes the same task as this plugin, but uses LSP instead of Treesitter. It also adds ability to have coloured icons!\n\n# 🛰️ nvim-gps\n\nTake this handy dandy gps with you on your coding adventures and always know where you are!\n\n## 🤔 What is nvim-gps?\n\nnvim-gps is a simple status line component that shows context of the current cursor position in file. It is similar to the statusline function provided by [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter/blob/af96150a2d34a05b7265ee3c42425315bcd62e39/doc/nvim-treesitter.txt#L414), but smarter. Using custom treesitter queries for each language, nvim-gps is able to show exact name of containing class, struct, function, method, etc. along with some fancy symbols!\n\n![example](https://user-images.githubusercontent.com/43147494/130349444-fa7176a3-d068-4309-87ec-bcf6f0204261.png)\n\nHere is a barebones example how it looks in a statusline\n\n![nvim-gps-barebone-demo](https://user-images.githubusercontent.com/43147494/130415000-6ae9c965-d631-41b2-b1f0-40ad4840a192.gif)\n\nHere is a example of how it can look in a fully configured statusline\n\n![nvim-gps-demo](https://user-images.githubusercontent.com/43147494/130349453-d3e1fd61-348e-439c-b013-3433fd284323.gif)\n\n## ✅ Supported Languages\n\n* Bash (and Zsh)\n* C\n* C++\n* C#\n* Fennel\n* Go\n* Haskell\n* Html\n* Java\n* Javascript (and jsx)\n* JSON\n* LaTeX\n* Lua\n* Norg\n* Nix\n* Ocaml\n* Php\n* Python\n* Ruby\n* Rust\n* TOML\n* Typescript (and tsx)\n* Verilog\n* YAML\n* YANG\n* Zig\n\n## ⚡️ Requirements\n\n* Neovim \u003e= 0.5.0\n* [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)\n\n## 📦 Installation\n\nInstall the plugin with your preferred package manager:\n\n### [packer](https://github.com/wbthomason/packer.nvim)\n\n```lua\n-- Lua\nuse {\n\t\"SmiteshP/nvim-gps\",\n\trequires = \"nvim-treesitter/nvim-treesitter\"\n}\n```\n\n### [vim-plug](https://github.com/junegunn/vim-plug)\n\n```vim\n\" Vimscript\nPlug \"nvim-treesitter/nvim-treesitter\"\nPlug \"SmiteshP/nvim-gps\"\n```\n\n## ⚙️ Configuration\n\nnvim-gps provides a `setup` function that takes in a table with configuration options.\nThe default configuration assumes that you are using a nerd font.\n\n\u003e Note: `setup` function needs to be called once for nvim-gps to work.\n\n```lua\n-- Lua\n\n-- Default config\nrequire(\"nvim-gps\").setup()\n```\n\n```lua\n-- Lua\n\n-- Customized config\nrequire(\"nvim-gps\").setup({\n\n\tdisable_icons = false,           -- Setting it to true will disable all icons\n\n\ticons = {\n\t\t[\"class-name\"] = ' ',      -- Classes and class-like objects\n\t\t[\"function-name\"] = ' ',   -- Functions\n\t\t[\"method-name\"] = ' ',     -- Methods (functions inside class-like objects)\n\t\t[\"container-name\"] = '⛶ ',  -- Containers (example: lua tables)\n\t\t[\"tag-name\"] = '炙'         -- Tags (example: html tags)\n\t},\n\n\t-- Add custom configuration per language or\n\t-- Disable the plugin for a language\n\t-- Any language not disabled here is enabled by default\n\tlanguages = {\n\t\t-- Some languages have custom icons\n\t\t[\"json\"] = {\n\t\t\ticons = {\n\t\t\t\t[\"array-name\"] = ' ',\n\t\t\t\t[\"object-name\"] = ' ',\n\t\t\t\t[\"null-name\"] = '[] ',\n\t\t\t\t[\"boolean-name\"] = 'ﰰﰴ ',\n\t\t\t\t[\"number-name\"] = '# ',\n\t\t\t\t[\"string-name\"] = ' '\n\t\t\t}\n\t\t},\n\t\t[\"latex\"] = {\n\t\t\ticons = {\n\t\t\t\t[\"title-name\"] = \"# \",\n\t\t\t\t[\"label-name\"] = \" \",\n\t\t\t},\n\t\t},\n\t\t[\"norg\"] = {\n\t\t\ticons = {\n\t\t\t\t[\"title-name\"] = \" \",\n\t\t\t},\n\t\t},\n\t\t[\"toml\"] = {\n\t\t\ticons = {\n\t\t\t\t[\"table-name\"] = ' ',\n\t\t\t\t[\"array-name\"] = ' ',\n\t\t\t\t[\"boolean-name\"] = 'ﰰﰴ ',\n\t\t\t\t[\"date-name\"] = ' ',\n\t\t\t\t[\"date-time-name\"] = ' ',\n\t\t\t\t[\"float-name\"] = ' ',\n\t\t\t\t[\"inline-table-name\"] = ' ',\n\t\t\t\t[\"integer-name\"] = '# ',\n\t\t\t\t[\"string-name\"] = ' ',\n\t\t\t\t[\"time-name\"] = ' '\n\t\t\t}\n\t\t},\n\t\t[\"verilog\"] = {\n\t\t\ticons = {\n\t\t\t\t[\"module-name\"] = ' '\n\t\t\t}\n\t\t},\n\t\t[\"yaml\"] = {\n\t\t\ticons = {\n\t\t\t\t[\"mapping-name\"] = ' ',\n\t\t\t\t[\"sequence-name\"] = ' ',\n\t\t\t\t[\"null-name\"] = '[] ',\n\t\t\t\t[\"boolean-name\"] = 'ﰰﰴ ',\n\t\t\t\t[\"integer-name\"] = '# ',\n\t\t\t\t[\"float-name\"] = ' ',\n\t\t\t\t[\"string-name\"] = ' '\n\t\t\t}\n\t\t},\n\t\t[\"yang\"] = {\n\t\t\ticons = {\n\t\t\t\t[\"module-name\"] = \" \",\n\t\t\t\t[\"augment-path\"] = \" \",\n\t\t\t\t[\"container-name\"] = \" \",\n\t\t\t\t[\"grouping-name\"] = \" \",\n\t\t\t\t[\"typedef-name\"] = \" \",\n\t\t\t\t[\"identity-name\"] = \" \",\n\t\t\t\t[\"list-name\"] = \"﬘ \",\n\t\t\t\t[\"leaf-list-name\"] = \" \",\n\t\t\t\t[\"leaf-name\"] = \" \",\n\t\t\t\t[\"action-name\"] = \" \",\n\t\t\t}\n\t\t},\n\n\t\t-- Disable for particular languages\n\t\t-- [\"bash\"] = false, -- disables nvim-gps for bash\n\t\t-- [\"go\"] = false,   -- disables nvim-gps for golang\n\n\t\t-- Override default setting for particular languages\n\t\t-- [\"ruby\"] = {\n\t\t--\tseparator = '|', -- Overrides default separator with '|'\n\t\t--\ticons = {\n\t\t--\t\t-- Default icons not specified in the lang config\n\t\t--\t\t-- will fallback to the default value\n\t\t--\t\t-- \"container-name\" will fallback to default because it's not set\n\t\t--\t\t[\"function-name\"] = '',    -- to ensure empty values, set an empty string\n\t\t--\t\t[\"tag-name\"] = ''\n\t\t--\t\t[\"class-name\"] = '::',\n\t\t--\t\t[\"method-name\"] = '#',\n\t\t--\t}\n\t\t--}\n\t},\n\n\tseparator = ' \u003e ',\n\n\t-- limit for amount of context shown\n\t-- 0 means no limit\n\tdepth = 0,\n\n\t-- indicator used when context hits depth limit\n\tdepth_limit_indicator = \"..\"\n})\n```\n\n## 🚀 Usage\n\nnvim-gps doesn't modify your statusline by itself, instead you are provided with two functions and it is left up to you to incorporate them into your statusline.\n\n```lua\n-- Lua\nlocal gps = require(\"nvim-gps\")\n\ngps.is_available()  -- Returns boolean value indicating whether a output can be provided\ngps.get_location()  -- Returns a string with context information (or nil if not available)\n\n-- example output: \"mystruct \u003e sum\"\n```\n\n\n\u003cdetails\u003e\n\u003csummary\u003e You can also pass optional arguments to \u003ccode\u003eget_location\u003c/code\u003e function to override options given in setup function: \u003c/summary\u003e\n\n```lua\nopts = {\n\tdisable_icons = false,\n\tseparator = ' \u003e ',\n\tdepth = 0,\n\tdepth_limit_indicator = \"..\"\n}\n\ngps.get_location(opts)\n```\n\n\u003c/details\u003e\n\nThese two functions should satisfy the needs of most users, however if you want the raw intermediate data for custom usage you can use the following function:\n\n```lua\ngps.get_data()      -- Returns a table of intermediate representation of data (which is used by get_location)\n                    -- Table of tables that contain 'text', 'type' and 'icon' for each context\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eAn example output of \u003ccode\u003eget_data\u003c/code\u003e function: \u003c/summary\u003e\n\n```lua\n {\n \t{\n\t\ttext = \"mystruct\",\n\t\ttype = \"class-name\",\n\t\ticon = \" \"\n\t},\n\t{\n\t\ttext = \"sum\",\n\t\ttype = \"method-name\",\n\t\ticon = \" \"\n\t}\n }\n```\n\n\u003c/details\u003e\n\n\n\n## Examples of Integrating with Other Plugins\n\n### [feline](https://github.com/famiu/feline.nvim)\n\n\u003cdetails\u003e\n\u003csummary\u003eAn example feline setup \u003c/summary\u003e\n\n```lua\n-- Lua\nlocal gps = require(\"nvim-gps\")\n\ntable.insert(components.active[1], {\n\tprovider = function()\n\t\treturn gps.get_location()\n\tend,\n\tenabled = function()\n\t\treturn gps.is_available()\n\tend\n})\n```\n\n\u003c/details\u003e\n\n### [galaxyline](https://github.com/glepnir/galaxyline.nvim)\n\n\u003cdetails\u003e\n\u003csummary\u003eAn example galaxyline setup \u003c/summary\u003e\n\n```lua\n-- Lua\nlocal gps = require(\"nvim-gps\")\n\nrequire('galaxyline').section.left[1]= {\n\tnvimGPS = {\n\t\tprovider = function()\n\t\t\treturn gps.get_location()\n\t\tend,\n\t\tcondition = function()\n\t\t\treturn gps.is_available()\n\t\tend\n\t}\n}\n```\n\n\u003c/details\u003e\n\n### [lualine](https://github.com/hoob3rt/lualine.nvim)\n\n\u003cdetails\u003e\n\u003csummary\u003eAn example lualine setup \u003c/summary\u003e\n\n```lua\n-- Lua\nlocal gps = require(\"nvim-gps\")\n\nrequire(\"lualine\").setup({\n\tsections = {\n\t\t\tlualine_c = {\n\t\t\t\t{ gps.get_location, cond = gps.is_available },\n\t\t\t}\n\t}\n})\n```\n\n\u003c/details\u003e\n\n### vimscript\n\n\u003cdetails\u003e\n\u003csummary\u003e example setup using native vim way \u003c/summary\u003e\n\n```vim\n\" vimscript\nfunc! NvimGps() abort\n\treturn luaeval(\"require'nvim-gps'.is_available()\") ?\n\t\t\\ luaeval(\"require'nvim-gps'.get_location()\") : ''\nendf\n\nset statusline+=%{NvimGps()}\n```\n\n\u003c/details\u003e\n\n### [windline](https://github.com/windwp/windline.nvim)\n\n\u003cdetails\u003e\n\u003csummary\u003e example windline setup \u003c/summary\u003e\n\n```lua\n-- Lua\nlocal gps = require(\"nvim-gps\")\n\ncomps.gps = {\n\tfunction()\n\t\tif gps.is_available() then\n\t\t\treturn gps.get_location()\n\t\tend\n\t\treturn ''\n\tend,\n\t{\"white\", \"black\"}\n}\n```\n\n\u003c/details\u003e\n\n## 🔥 Contributions\n\nIs your favorite language not supported? Or did you find something not being captured by the nvim-gps? Please consider opening a issue, or even better make a PR and solve the issue!! 😄\n\nPlease read the CONTRIBUTING.md to understand how the treesitter queries work and how you can add/enhance the queries for your favorite programming languages!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSmiteshP%2Fnvim-gps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSmiteshP%2Fnvim-gps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSmiteshP%2Fnvim-gps/lists"}