Skip to content

Commit

Permalink
feat: use cody-agent as the backend (#30)
Browse files Browse the repository at this point in the history
- create build/init.lua for building the project
- use jsonrpc for communication (cody-agent and sg-nvim-agent)
- add doc/sg.txt
- add tos
- vendor lsp rpc client and vim system (can remove when 0.10 support only)
- addditional tests for sg-cody, sg-agent
- vendor telescope debounce
- add :SourcegraphBuild
  • Loading branch information
tjdevries committed Jul 17, 2023
1 parent 3574508 commit b65aade
Show file tree
Hide file tree
Showing 96 changed files with 4,490 additions and 1,239 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/cody-agent.js binary
83 changes: 83 additions & 0 deletions .github/workflows/docgen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Generate docs

on:
push:
branches-ignore:
- master

jobs:
build-sources:
name: Generate docs
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz
steps:
- uses: actions/checkout@v3
- run: date +%F > todays-date
- name: Restore cache for today's nightly.
uses: actions/cache@v3
with:
path: _neovim
key: ${{ runner.os }}-${{ matrix.url }}-${{ hashFiles('todays-date') }}

- name: Cache rust items
uses: actions/cache@v3
with:
path: |
~/.rustup/
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Prepare
run: |
test -d _neovim || {
mkdir -p _neovim
curl -sL ${{ matrix.url }} | tar xzf - --strip-components=1 -C "${PWD}/_neovim"
}
mkdir -p ~/.local/share/nvim/site/pack/vendor/start
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
git clone https://github.com/tjdevries/tree-sitter-lua ~/.local/share/nvim/site/pack/vendor/start/tree-sitter-lua
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
- name: Run build scripts
run: |
export PATH="${PWD}/_neovim/bin:${PATH}"
export VIM="${PWD}/_neovim/share/nvim/runtime"
nvim -l build/init.lua
- name: Build parser
run: |
# We have to build the parser every single time to keep up with parser changes
cd ~/.local/share/nvim/site/pack/vendor/start/tree-sitter-lua
make dist
cd -
- name: Generating docs
run: |
export PATH="${PWD}/_neovim/bin:${PATH}"
export VIM="${PWD}/_neovim/share/nvim/runtime"
nvim --version
nvim -l scripts/gendocs.lua
# inspired by nvim-lspconfigs
- name: Update documentation
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_MSG: |
[docgen] Update doc/sg.txt
skip-checks: true
run: |
git config user.email "actions@github"
git config user.name "Github Actions"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git add doc/
# Only commit and push if we have changes
git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push origin HEAD:${GITHUB_REF})
19 changes: 10 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ jobs:
include:
- os: ubuntu-22.04
rev: nightly/nvim-linux64.tar.gz
# manager: sudo apt-get
# packages: -y ripgrep
- os: ubuntu-22.04
rev: v0.9.0/nvim-linux64.tar.gz
# manager: sudo apt-get
# packages: -y ripgrep
- os: macos-latest
rev: nightly/nvim-macos.tar.gz
steps:
- uses: actions/checkout@v3
- run: date +%F > todays-date
Expand All @@ -42,10 +40,6 @@ jobs:
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build rust items
run: |
cargo build --workspace --bins
- name: Prepare
run: |
# ${{ matrix.manager }} update
Expand All @@ -58,9 +52,16 @@ jobs:
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
- name: Run build scripts
run: |
export PATH="${PWD}/_neovim/bin:${PATH}"
export VIM="${PWD}/_neovim/share/nvim/runtime"
nvim -l build/init.lua
- name: Run tests
run: |
export PATH="${PWD}/_neovim/bin:${PATH}"
export VIM="${PWD}/_neovim/share/nvim/runtime"
nvim --version
make test
nvim -l scripts/test.lua
39 changes: 37 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 26 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,54 @@
[package]
name = "sg"
version = "0.1.1"
edition = "2018"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow.workspace = true
mlua.workspace = true
tokio.workspace = true
serde.workspace = true
serde_json.workspace = true
graphql_client.workspace = true
reqwest.workspace = true
lsp-types.workspace = true

anyhow = "1"
graphql_client = { version = "0.13.0", features = ["reqwest", "reqwest-blocking"] }
regex = "1.4.6"
reqwest = "0.11.3"
serde = "1.0.125"
futures = "0.3.17"
lsp-server = "0.7.0"
lsp-types = "0.94.0"
serde_json = "1.0"
log4rs = "1.2"
log = "0.4"
once_cell = "1"

userdata_defaults = { path = "crates/userdata_defaults/" }
userdata_defaults = { path = "crates/userdata-defaults/" }
sg-gql = { path = "crates/sg-gql" }
sg-types = { path = "crates/sg-types" }
jsonrpc = { path = "crates/jsonrpc" }

[workspace.dependencies]
anyhow = "1"
mlua = { version = "0.8", features = ["luajit", "vendored", "module", "serialize", "async"] }
tokio = { version = "1", features = ["full"] }

serde = "1.0.125"
serde_json = "1.0"

graphql_client = { version = "0.13.0", features = ["reqwest", "reqwest-blocking"] }
reqwest = "0.11.3"

lsp-types = "0.94.0"
url = "2.4.0"

[lib]
name = "sg"
path = "lib/sg.rs"

[workspace]
members = [
"crates/sg-nvim/",
"crates/userdata_defaults/",
"crates/jsonrpc",
"crates/libsg/",
"crates/sg-gql/",
"crates/sg-types/",
"crates/userdata-defaults/",
]
3 changes: 0 additions & 3 deletions Makefile

This file was deleted.

Loading

0 comments on commit b65aade

Please sign in to comment.