You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In your `settings.json`, you add the `lsp.server` option in order to enable using it for your languages' server.
33
+
In your `settings.json`, you add the `lsp.server` option in order to enable
34
+
using it for your languages' server.
35
35
36
36
Example:
37
37
@@ -42,33 +42,36 @@ Example:
42
42
}
43
43
```
44
44
45
-
The format for the `lsp.server` value is a comma-separated list for each file type you want to boot up a language server:
45
+
The format for the `lsp.server` value is a comma-separated list for each file
46
+
type you want to boot up a language server:
46
47
47
48
```
48
49
<file type>=<executable with arguments where necessary>[=<initialization options passed to language server>][,...]
49
50
```
50
51
51
-
If you encounter an issue whereby the `lsp.server` settings configuration is auto-removed when you change any other configuration option,
52
-
you can use an environment variable called `MICRO_LSP` to define the same information. You can add a line such as the following to your shell profile (e.g. .bashrc):
52
+
If you encounter an issue whereby the `lsp.server` settings configuration is
53
+
auto-removed when you change any other configuration option, you can use an
54
+
environment variable called `MICRO_LSP` to define the same information. You can
55
+
add a line such as the following to your shell profile (e.g. .bashrc):
Not all possible types of modification events to the file are currently being sent to the language server. Saving the file will re-synchronize it, though.
76
+
Not all possible types of modification events to the file are currently being
77
+
sent to the language server. Saving the file will re-synchronize it, though.
Remember to add comma to previous line. Depending on the language server, automatic code formating can be quite opinionated. In that case, you can simply set lsp.formatOnSave to false.
44
+
Remember to add comma to previous line. Depending on the language server,
45
+
automatic code formating can be quite opinionated. In that case, you can simply
46
+
set lsp.formatOnSave to false.
43
47
44
-
For Python language server, the currently maintained fork is 'pylsp'. If you wish to use the Palantir version (last updated in 2020) instead, set "python=pyls" in lsp.server.
48
+
For Python language server, the currently maintained fork is 'pylsp'. If you
49
+
wish to use the Palantir version (last updated in 2020) instead, set
50
+
"python=pyls" in lsp.server.
45
51
46
-
If your lsp.server settings are autoremoved, you can
52
+
If your lsp.server settings are autoremoved, you can
To support each language, LSP plugin uses language servers. To use LSP plugin, you must install at least one language server.
58
+
To support each language, LSP plugin uses language servers. To use LSP plugin,
59
+
you must install at least one language server.
53
60
54
-
If you want to quickly test LSP plugin, Go language server gopls is simple to install.
61
+
If you want to quickly test LSP plugin, Go language server gopls is simple to
62
+
install.
55
63
56
64
### gopls, Go language server
57
65
58
66
You will need command 'gopls'
59
67
60
-
$ gopls version
61
-
golang.org/x/tools/gopls v0.7.3
68
+
$ gopls version
69
+
golang.org/x/tools/gopls v0.7.3
62
70
63
71
In Debian, this is installed with
64
72
65
-
$ sudo apt-get update
66
-
$ sudo apt-get -y install golang-go gopls
73
+
$ sudo apt-get update
74
+
$ sudo apt-get -y install golang-go gopls
67
75
68
76
To test it, write a short go program
69
77
70
-
$ micro hello.go
78
+
$ micro hello.go
71
79
72
80
```go
73
81
package main
@@ -79,58 +87,77 @@ func main() {
79
87
}
80
88
```
81
89
82
-
Move cursor over Println and press alt-k. The function signature is shown on the bottom of the screen, in Micro status bar. It shows you what parameters the function can take. The signature should look similar to this: "func fmt.Println(a ...interface{}) (n int, err error)Println formats using the default formats..."
90
+
Move cursor over Println and press alt-k. The function signature is shown on the
91
+
bottom of the screen, in Micro status bar. It shows you what parameters the
92
+
function can take. The signature should look similar to this: "func
93
+
fmt.Println(a ...interface{}) (n int, err error)Println formats using the
94
+
default formats..."
83
95
84
-
Can you see the function signature with alt-k? If you can, you have succesfully installed Micro LSP plugin and GoPLS language server.
96
+
Can you see the function signature with alt-k? If you can, you have succesfully
97
+
installed Micro LSP plugin and GoPLS language server.
85
98
86
-
Keep your cursor over Println, and press alt-d. The file defining Println opens. In this case, it's fmt/print.go. As Go reference documentation is in code comments, this is very convenient. You can navigate between tabs with atl-, (alt-comma) and alt-. (alt - full stop). To close the tab, press Ctrl-Q.
99
+
Keep your cursor over Println, and press alt-d. The file defining Println opens.
100
+
In this case, it's fmt/print.go. As Go reference documentation is in code
101
+
comments, this is very convenient. You can navigate between tabs with atl-,
102
+
(alt-comma) and alt-. (alt - full stop). To close the tab, press Ctrl-Q.
87
103
88
104
### pylsp, Python language server
89
105
90
106
Installing Python language server PyLSP is a bit more involved.
91
107
92
-
You will need 'virtualenv' command to create virtual environments and 'pip' to install Python packages. You can also use one of the many other commands for keeping your 'pip' packages in order.
108
+
You will need 'virtualenv' command to create virtual environments and 'pip' to
109
+
install Python packages. You can also use one of the many other commands for
110
+
keeping your 'pip' packages in order.
93
111
94
112
In Debian, these are installed with
95
113
96
-
$ sudo apt-get update
97
-
$ sudo apt-get install python-pip virtualenv
114
+
$ sudo apt-get update
115
+
$ sudo apt-get install python-pip virtualenv
98
116
99
117
Create a new virtual environment
100
118
101
-
$ mkdir somePythonProject; cd somePythonProject
102
-
$ virtualenv -p python3 env/
103
-
$ source env/bin/activate
119
+
$ mkdir somePythonProject; cd somePythonProject
120
+
$ virtualenv -p python3 env/
121
+
$ source env/bin/activate
104
122
105
-
Your prompt likely shows "(env)" to confirm you're inside your virtual environment.
123
+
Your prompt likely shows "(env)" to confirm you're inside your virtual
124
+
environment.
106
125
107
-
List the packages you want installed.
126
+
List the packages you want installed.
108
127
109
-
$ micro requirements.txt
128
+
$ micro requirements.txt
110
129
111
-
This list is to provide the most useful suggestions. If you would like to get a lot more opinionated advice, such as adding two empty lines between functions, you could use "python-lsp-server[all]". The mypy package provides optional static type checking. requirements.txt:
130
+
This list is to provide the most useful suggestions. If you would like to get a
131
+
lot more opinionated advice, such as adding two empty lines between functions,
132
+
you could use "python-lsp-server[all]". The mypy package provides optional
Save with Ctrl-S. A red warning sign ">>" lists up in the gutter, on the left side of Micro. Move cursor to the line "return a". The status bar shows the warning: "undefined name 'a'". Well done, you have now installed Python LSP support for Micro.
153
+
Save with Ctrl-S. A red warning sign ">>" lists up in the gutter, on the left
154
+
side of Micro. Move cursor to the line "return a". The status bar shows the
155
+
warning: "undefined name 'a'". Well done, you have now installed Python LSP
156
+
support for Micro.
132
157
133
-
MyPy provides optional static type setting. You can write normally, and type checking is ignored. You can define types for some functions, and you get automatic warnings for incorrect use of types. This is how types are marked:
158
+
MyPy provides optional static type setting. You can write normally, and type
159
+
checking is ignored. You can define types for some functions, and you get
160
+
automatic warnings for incorrect use of types. This is how types are marked:
134
161
135
162
```python
136
163
defsquare(x: int) -> int:
@@ -153,5 +180,4 @@ def square(x: int) -> int:
153
180
154
181
[rls - Rust Language Server](https://github.com/rust-lang/rls)
155
182
156
-
[lua-lsp - A Lua language server ](https://github.com/Alloyed/lua-lsp)
157
-
183
+
[lua-lsp - A Lua language server](https://github.com/Alloyed/lua-lsp)
0 commit comments