Skip to content

Commit

Permalink
Merge remote-tracking branch 'base/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
bekaboo committed Dec 23, 2023
2 parents c20d474 + c9f2b42 commit d76de3e
Show file tree
Hide file tree
Showing 70 changed files with 7,678 additions and 820 deletions.
19 changes: 3 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: true
matrix:
neovim_branch: ['v0.8.2']
neovim_branch: ['v0.8.2', 'v0.9.1']
runs-on: ubuntu-latest
env:
NEOVIM_BRANCH: ${{ matrix.neovim_branch }}
Expand All @@ -21,27 +21,14 @@ jobs:

- name: Setup build dependencies
run: |
sudo apt update &&
sudo apt install -y \
autoconf \
automake \
sudo apt-get update &&
sudo apt-get install -y \
cmake \
g++ \
gettext \
gperf \
libjemalloc-dev \
libluajit-5.1-dev \
libmsgpack-dev \
libtermkey-dev \
libtool \
libtool-bin \
libunibilium-dev \
libvterm-dev \
lua-bitop \
lua-lpeg \
lua-mpack \
ninja-build \
pkg-config \
unzip
- name: Cache neovim
Expand Down
23 changes: 23 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"runtime": {
"version": "LuaJIT"
},
"workspace.library": [
"$VIMRUNTIME",
"${3rd}/busted/library",
"${3rd}/luv/library"
],
"workspace.checkThirdParty": false,
"diagnostics": {
"groupFileStatus": {
"strict": "Opened",
"strong": "Opened"
},
"groupSeverity": {
"strong": "Warning",
"strict": "Warning"
},
"unusedLocalExclude": [ "_*" ]
}
}
6 changes: 6 additions & 0 deletions .stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
column_width = 100
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
call_parentheses = "Always"
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DEFAULT_GOAL := test

NEOVIM_BRANCH := master
NEOVIM_BRANCH := v0.9.1

FILTER=.*

Expand All @@ -17,6 +17,7 @@ nvim-treesitter:
git clone --depth 1 https://github.com/nvim-treesitter/nvim-treesitter

nvim-treesitter/parser/%.so: nvim-treesitter $(NEOVIM)
$(RM) -r $@
VIMRUNTIME=$(NEOVIM)/runtime $(NEOVIM)/build/bin/nvim \
--headless \
--clean \
Expand All @@ -26,13 +27,17 @@ nvim-treesitter/parser/%.so: nvim-treesitter $(NEOVIM)

export VIMRUNTIME=$(PWD)/$(NEOVIM)/runtime

BUSTED = $$( [ -f $(NEOVIM)/test/busted_runner.lua ] \
&& echo "$(NEOVIM)/build/bin/nvim -ll $(NEOVIM)/test/busted_runner.lua" \
|| echo "$(NEOVIM)/.deps/usr/bin/busted" )

.PHONY: test
test: $(NEOVIM) nvim-treesitter \
nvim-treesitter/parser/cpp.so \
nvim-treesitter/parser/lua.so \
nvim-treesitter/parser/rust.so \
nvim-treesitter/parser/typescript.so
$(NEOVIM)/.deps/usr/bin/busted \
$(BUSTED) \
-v \
--lazy \
--helper=$(PWD)/test/preload.lua \
Expand Down
57 changes: 29 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
# nvim-treesitter-context

Lightweight alternative to [context.vim](https://github.com/wellle/context.vim)
implemented with [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).

## Requirements

Neovim >= v0.8.2
Neovim >= v0.9.0

Note: if you need support for Neovim 0.6.x please use the tag `compat/0.6`.

## Install

via vim-plug

```vim
Plug 'nvim-treesitter/nvim-treesitter'
Plug 'nvim-treesitter/nvim-treesitter-context'
```

via packer

```lua
use 'nvim-treesitter/nvim-treesitter'
use 'nvim-treesitter/nvim-treesitter-context'
```

## Screenshot

![theme](./static/demo.gif)
Expand All @@ -37,27 +20,42 @@ use 'nvim-treesitter/nvim-treesitter-context'
- [x] `c`
- [x] `c_sharp`
- [x] `capnp`
- [x] `clojure`
- [x] `cmake`
- [x] `cpp`
- [x] `css`
- [x] `cuda`
- [x] `cue`
- [x] `d`
- [x] `dart`
- [x] `elixir`
- [x] `fennel`
- [x] `fish`
- [x] `fortran`
- [x] `glimmer`
- [x] `go`
- [x] `graphql`
- [x] `haskell`
- [x] `html_tags`
- [x] `ini`
- [x] `janet` (using the "janet_simple" grammar)
- [x] `java`
- [x] `javascript`
- [x] `json`
- [x] `jsonnet`
- [x] `julia`
- [x] `latex`
- [x] `liquidsoap`
- [x] `lua`
- [x] `markdown`
- [x] `matlab`
- [x] `nim`
- [x] `nix`
- [x] `norg`
- [x] `objdump`
- [x] `ocaml_interface`
- [x] `ocaml`
- [x] `odin`
- [x] `php`
- [x] `prisma`
- [x] `python`
Expand All @@ -67,15 +65,22 @@ use 'nvim-treesitter/nvim-treesitter-context'
- [x] `scala`
- [x] `scss`
- [x] `smali`
- [x] `solidity`
- [x] `swift`
- [x] `tcl`
- [x] `teal`
- [x] `templ`
- [x] `terraform`
- [x] `toml`
- [x] `tsx`
- [x] `typescript`
- [x] `typoscript`
- [x] `usd`
- [x] `verilog`
- [x] `vim`
- [x] `xml`
- [x] `yaml`
- [x] `yang`
- [x] `zig`
- [ ] `ada`
- [ ] `agda`
Expand All @@ -87,11 +92,9 @@ use 'nvim-treesitter/nvim-treesitter-context'
- [ ] `blueprint`
- [ ] `chatito`
- [ ] `clojure`
- [ ] `cmake`
- [ ] `commonlisp`
- [ ] `cooklang`
- [ ] `cpon`
- [ ] `d`
- [ ] `devicetree`
- [ ] `dhall`
- [ ] `dockerfile`
Expand All @@ -112,14 +115,12 @@ use 'nvim-treesitter/nvim-treesitter-context'
- [ ] `gdscript`
- [ ] `git_rebase`
- [ ] `gleam`
- [ ] `glimmer`
- [ ] `glsl`
- [ ] `godot_resource`
- [ ] `gomod`
- [ ] `gosum`
- [ ] `gowork`
- [ ] `hack`
- [ ] `haskell`
- [ ] `hcl`
- [ ] `heex`
- [ ] `hjson`
Expand All @@ -132,9 +133,7 @@ use 'nvim-treesitter/nvim-treesitter-context'
- [ ] `jsdoc`
- [ ] `json5`
- [ ] `jsonc`
- [ ] `jsonnet`
- [ ] `jsx`
- [ ] `julia`
- [ ] `kdl`
- [ ] `kotlin`
- [ ] `lalrpop`
Expand All @@ -145,7 +144,6 @@ use 'nvim-treesitter/nvim-treesitter-context'
- [ ] `mermaid`
- [ ] `meson`
- [ ] `nickel`
- [ ] `nix`
- [ ] `ocamllex`
- [ ] `pascal`
- [ ] `perl`
Expand All @@ -169,7 +167,6 @@ use 'nvim-treesitter/nvim-treesitter-context'
- [ ] `scheme`
- [ ] `slint`
- [ ] `smithy`
- [ ] `solidity`
- [ ] `sparql`
- [ ] `sql`
- [ ] `starlark`
Expand All @@ -191,7 +188,6 @@ use 'nvim-treesitter/nvim-treesitter-context'
- [ ] `vue`
- [ ] `wgsl`
- [ ] `wgsl_bevy`
- [ ] `yang`
- [ ] `yuck`
</details>
Expand All @@ -200,13 +196,15 @@ use 'nvim-treesitter/nvim-treesitter-context'

(Default values are shown below)

Note: calling `setup()` is optional.

```lua
require'treesitter-context'.setup{
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit.
line_numbers = true,
multiline_threshold = 20, -- Maximum number of lines to collapse for a single context line
multiline_threshold = 20, -- Maximum number of lines to show for a single context
trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer'
mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline'
-- Separator between context and content. Should be a single character string, like '-'.
Expand All @@ -229,6 +227,9 @@ context. Per default it links to `NormalFloat`.
Use the highlight group `TreesitterContextLineNumber` to change the colors of the
context line numbers if `line_numbers` is set. Per default it links to `LineNr`.

Use the highlight group `TreesitterContextSeparator` to change the colors of the
separator if `separator` is set. By default it links to `FloatBorder`.

Use the highlight group `TreesitterContextBottom` to change the highlight of the
last line of the context window. By default it links to `NONE`.
However, you can use this to create a border by applying an underline highlight, e.g:
Expand Down
Loading

0 comments on commit d76de3e

Please sign in to comment.