diff --git a/README.md b/README.md index 1902e2f..ca1f9a2 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ that list is a table with the following attributes: | `line` | Line and column positions | | `lsp` | Diagnostics from Neovim LSP client | | `mode` | Current mode | +| `treesitter-context` | Current treesitter node (requires [nvim-gps](https://github.com/SmiteshP/nvim-gps)) | | `whitespace` | Trailing whitespaces, mixed indent and Git conflict markers warnings | | `wordcount` | Current word count (enabled only for [some filetypes](https://github.com/ojroques/nvim-hardline/blob/5fc738bb7991f7d7890be14e7a74a50e21f0bd81/lua/hardline/parts/wordcount.lua#L8-L19)) | diff --git a/lua/hardline/parts/treesitter-context.lua b/lua/hardline/parts/treesitter-context.lua new file mode 100644 index 0000000..accdbf7 --- /dev/null +++ b/lua/hardline/parts/treesitter-context.lua @@ -0,0 +1,17 @@ +local ok, gps = pcall(require, "nvim-gps") +if not ok then gps = nil end + +local function get_context() + if not gps or not gps.is_available() then + return "" + end + return gps.get_location() +end + +local function get_item() + return get_context() +end + +return { + get_item = get_item, +}