-
Notifications
You must be signed in to change notification settings - Fork 184
/
editors.Rmd
189 lines (128 loc) · 5.66 KB
/
editors.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
---
title: "Editor setup"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Editor setup}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
in_pkgdown <- identical(Sys.getenv("IN_PKGDOWN"), "true")
maybe_still <- function(url) {
if (in_pkgdown) {
url
} else {
gsub("\\.gif$", "-still.gif", url)
}
}
```
```{r, echo = FALSE, results = 'asis'}
if (!in_pkgdown) {
cat(
"Note: This vignette is best viewed [online](https://lintr.r-lib.org/articles/editors.html),",
"where we can render full animations of editor flows.\n"
)
}
```
## RStudio
lintr lints are automatically displayed in the RStudio Markers pane (RStudio versions \> v0.99.206).
![RStudio Example](rstudio.png "Rstudio Example")
In order to show the "Markers" pane in RStudio: Menu "Tools" -\> "Global Options...", a window with title "Options" will pop up.
In that window: click "Code" on the left; click "Diagnostics" tab; check "Show diagnostics for R".
To lint a source file `test.R` type in the Console `lintr::lint("test.R")` and look at the result in the "Markers" pane.
This package also includes two addins for linting the current source and package.
To bind the addin to a keyboard shortcut navigate to Tools \> addins \> Browse Addins \> Keyboard Shortcuts.
It's recommended to use Alt+Shift+L for linting the current source lint and Ctrl+Shift+Alt+L to code the package.
These are easy to remember as you are Alt+Shift+L(int) ;)
## Emacs
lintr has [built-in integration](http://www.flycheck.org/en/latest/languages.html#r) with [flycheck](https://github.com/flycheck/flycheck) versions greater than `0.23`.
![Emacs Example](`r maybe_still("emacs.gif")` "Emacs Example")
### Installation
lintr is fully integrated into flycheck when using [ESS](http://ess.r-project.org/).
See the installation documentation for those packages for more information.
### Configuration
You can also configure what linters are used.
e.g. using a different line length cutoff.
- `M-x customize-option` -\> `flycheck-lintr-linters` -\> `linters_with_defaults(line_length_linter(120))`
## Vim - syntastic
lintr can be integrated with [syntastic](https://github.com/vim-syntastic/syntastic) for on-the-fly linting.
![Vim Example](`r maybe_still("vim-syntastic.gif")` "Vim Example")
### Installation
Put the file [syntastic/lintr.vim](https://raw.githubusercontent.com/r-lib/lintr/v2.0.1/inst/syntastic/lintr.vim) in `syntastic/syntax_checkers/r`.
If you are using [pathogen](https://github.com/tpope/vim-pathogen) this directory is `~/.vim/bundles/syntastic/syntax_checkers/r`.
You will also need to add the following lines to your `.vimrc`.
``` vim
let g:syntastic_enable_r_lintr_checker = 1
let g:syntastic_r_checkers = ['lintr']
```
### Configuration
You can also configure what linters are used.
e.g. using a different line length cutoff.
``` vim
let g:syntastic_r_lintr_linters = "linters_with_defaults(line_length_linter(120))"
```
## Vim - ALE
lintr can be integrated with [ALE](https://github.com/dense-analysis/ale) for on the fly linting.
### Installation
lintr is integrated with ALE and requires no additional installation.
### Configuration
You can configure what linters are used, e.g. using a different line length cutoff.
``` vim
let g:ale_r_lintr_options = "linters_with_defaults(line_length_linter(120))"
```
You can also configure whether `lint` or `lint_package` is used.
Set to 1 for `lint_package` and 0 (default) for `lint`.
``` vim
let g:ale_r_lintr_lint_package = 1
```
See `:h ale_r_lintr` for more information.
Note that configuration through `.lintr` files are not supported.
There is a work around that can be used to read the contents of a `.lintr` file
in the root of the working directory. This would allow the use of configuration
through `.lintr` files.
``` vim
if filereadable(".lintr")
let g:ale_r_lintr_options = join(readfile('.lintr'))
endif
```
## Sublime Text 3
lintr can be integrated with [Sublime Linter](https://github.com/SublimeLinter/SublimeLinter) for on-the-fly linting.
![Sublime Example](`r maybe_still("sublime.gif")` "Sublime Example")
### Installation
Simply install `sublimeLinter-contrib-lintr` using [Package Control](https://packagecontrol.io/).
For more information see [Sublime Linter Docs](http://sublimelinter.readthedocs.io/en/latest/installation.html#installing-via-pc)
### Configuration
You can also configure what linters are used.
e.g. disabling the assignment linter and using a different line length cutoff.
In the SublimeLinter User Settings
```json
{
"linters": {
"lintr": {
"linters": "linters_with_defaults(assignment_linter = NULL, line_length_linter(120))"
}
}
}
```
## Atom
lintr can be integrated with [Linter](https://github.com/steelbrain/linter) for on the fly linting.
![Atom Example](atom.png "Atom Example")
### Installation
Simply install `linter-lintr` from within Atom or on the command line with:
``` bash
apm install linter-lintr
```
For more information and bug reports see [Atom linter-lintr](https://github.com/AtomLinter/linter-lintr).
## Visual Studio Code
In Visual Studio Code, [vscode-R](https://github.com/REditorSupport/vscode-R#r-extension-for-visual-studio-code) presents the lintr diagnostics from [languageserver](https://github.com/REditorSupport/languageserver).
![VS Code Example](vscode.png "VS Code Example")
### Installation
Installing `languageserver` package in R and `vscode-R` extension in VS Code will enable lintr in VS Code by default or run the following command lines:
``` bash
Rscript -e 'install.packages("languageserver")'
code --install-extension reditorsupport.r
```