Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add box.lsp integration #612

Merged
merged 32 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ea5f235
add box.linters styling functions. add check for treesitter dependencies
radbasa Aug 5, 2024
f0ab89f
chore: updates for better experience
radbasa Aug 21, 2024
51493bc
delint
radbasa Aug 21, 2024
ea2bc0d
add exclude_files argument
radbasa Aug 21, 2024
67aabbc
empty function needs same arguments
radbasa Aug 21, 2024
4b45e64
install treesitter and treesitter.r on E2E CI
radbasa Aug 22, 2024
10f4e2a
add install treesitter step
radbasa Aug 22, 2024
c3b031f
use rhino::pkg_install?
radbasa Aug 22, 2024
0225f57
revert github e2e workflow
radbasa Aug 22, 2024
8e74a80
install treesitter in lint-r test
radbasa Aug 22, 2024
a2f5f15
remove the R version check
radbasa Aug 22, 2024
ed579df
force-include treesitter and treesitter.r if R >= 4.3
radbasa Aug 26, 2024
fa0a81b
CI does not like getRversion()
radbasa Aug 27, 2024
631e7fd
remove default exclude files for styling. box.linters dependency hand…
radbasa Aug 28, 2024
74e1751
add box.lsp integration
radbasa Sep 3, 2024
eae5f03
delint
radbasa Sep 3, 2024
a37f75a
Merge branch 'integrate-box-linters-styling' into integrate-box-lsp
radbasa Sep 3, 2024
84bce0b
add e2e box.lsp test to e2e cicd pipeline
radbasa Sep 3, 2024
672a2ba
forgot to clean up DESCRIPTION after merge
radbasa Sep 3, 2024
bbdeb9d
start writing documentation
radbasa Sep 3, 2024
34fbbec
set minimum version for box.linters
radbasa Sep 4, 2024
84c0478
update format_r documentation
radbasa Sep 4, 2024
610ca0e
documentation for box.linters box::use styling
radbasa Sep 4, 2024
1ab3361
Merge branch 'integrate-box-linters-styling' into integrate-box-lsp
radbasa Sep 4, 2024
67c4574
moved box.lsp import for clarity
radbasa Sep 4, 2024
9ec1809
box.lsp documentation for rhino
radbasa Sep 4, 2024
994c8dc
delint
radbasa Sep 4, 2024
b803021
Merge branch 'integrate-box-linters-styling' into integrate-box-lsp
radbasa Sep 4, 2024
622931b
update wordlist
radbasa Sep 4, 2024
18d14a8
Merge branch 'main' into integrate-box-lsp
radbasa Sep 5, 2024
4f91d88
move user tools up
radbasa Sep 5, 2024
b18ffc5
documentation update on installing languageserver
radbasa Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ jobs:
cd RhinoApp
Rscript ../test-build-sass.R

- name: Rprofile should be configured for box.lsp
if: always()
run: |
cd RhinoApp
Rscript ../test-box-lsp.R

- name: test_r() should run testthat tests
if: always()
run: |
Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rhino
Title: A Framework for Enterprise Shiny Applications
Version: 1.9.0.9001
Version: 1.9.0.9002
Authors@R:
c(
person("Kamil", "Żyła", role = c("aut", "cre"), email = "[email protected]"),
Expand All @@ -25,6 +25,7 @@ Depends:
Imports:
box (>= 1.1.3),
box.linters (>= 0.10.4),
box.lsp,
cli,
config,
fs,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export(react_component)
export(test_e2e)
export(test_r)
import(box.linters)
import(box.lsp)
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# rhino (development version)

* Integrate `box.lsp` for auto-complete support for `box` modules in VS Code.
* Integrated {box.linters} styling functions to style `box::use()` calls according to the Rhino style guide.
* Added compatibility check for `treesitter` and `treesitter.r` dependencies

Expand Down
5 changes: 5 additions & 0 deletions R/linters.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@
# R CMD Check happy.
#' @import box.linters
NULL

# box.lsp is not used in the rhino package. It is used by a rhino app. Need to add this here
# to tell `R CMD Check` or `devtools::check()` we use `box.lsp`
#' @import box.lsp
NULL
2 changes: 2 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Rstudio
SDK
Stylelint
UI
VSCode
Webpack
autoreload
blogpost
Expand Down Expand Up @@ -48,6 +49,7 @@ nodejs
npm
nvm
overridable
parsers
pnpm
preconfigured
renv
Expand Down
7 changes: 7 additions & 0 deletions inst/templates/renv/dot.Rprofile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ if (file.exists("renv")) {

# Allow absolute module imports (relative to the app root).
options(box.path = getwd())

# box.lsp languageserver external hook
options(
languageserver.parser_hooks = list(
"box::use" = box.lsp::box_use_parser
)
)
6 changes: 5 additions & 1 deletion pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ navbar:
- text: Publish on Hugging Face
href: articles/how-to/publish-on-huggingface.html
- text: -------
- text: User tools
- text: Box-module auto-complete in VSCode
href: articles/how-to/box-lsp.html
- text: -------
- text: Migration guides
- text: Migration to Rhino 1.6
href: articles/how-to/migrate-1-6.html
Expand All @@ -116,7 +120,7 @@ navbar:
href: articles/how-to/migrate-1-8.html
- text: Migration to Rhino 1.9
href: articles/how-to/migrate-1-9.html

faq:
text: FAQ
href: articles/faq.html
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/test-box-lsp.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
testthat::expect_false(
is.null(getOption("languageserver.parser_hooks"))
)
23 changes: 23 additions & 0 deletions vignettes/how-to/box-lsp.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: "How-to: Auto-complete in VSCode"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{How-to: Auto-complete in VSCode}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

_Box-module auto-complete only works if one uses VSCode or Vim. It does not have any known adverse effects on RStudio Desktop or Posit Workbench._

# Introduction

Rhino utilizes `{box}` modules to manage large code bases. A disadvantage of `{box}` modules is the lack of syntax auto-complete support in RStudio or VSCode. In VSCode, auto-complete is provided by `{languageserver}` which allows for external parsers. [`{box.lsp}`](https://appsilon.github.io/box.lsp/index.html) is an extension to `{languageserver}` to provide function name and function argument auto-complete support for `{box}` modules. Please refer to the `{box.lsp}` [documentation](https://appsilon.github.io/box.lsp/index.html) for its current capabilities.

# Steps

1. Install `languageserver`: `renv::install("languageserver")`. `languageserver` is a developer tool, it is _not_ advised to add it to `dependencies.R` or to `renv.lock`.
2. If you initialized your Rhino app with version 1.10.0 or later, proceed to step 4.
3. If you are using an existing Rhino app with version < 1.10.0:
1. Install `box.lsp` to project dependencies: `rhino::pkg_install("box.lsp")`.
2. Run [`box.lsp::use_box_lsp()`](https://appsilon.github.io/box.lsp/reference/use_box_lsp.html) to update your project's `.Rprofile` file with `box.lsp` configuration.
4. Restart the R session (restart VSCode) to reload `.Rprofile`.
Loading