Skip to content

Commit 0d25fa4

Browse files
authoredFeb 14, 2025
feat(documentation): add installation instructions for Vim 8+ (#231)
Closes #207
1 parent 972da2a commit 0d25fa4

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
77
### Improvements
88

99
- feat(documentation): add missing functions to `stubs/` and adjust the format to match the rest of other stdlib doc `///` comments in https://github.com/tact-lang/tact-language-server/pull/189
10+
- feat(documentation): add installation instructions for Vim 8+ in https://github.com/tact-lang/tact-language-server/pull/231
1011

1112
### Fixed
1213

‎README.md

+63
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,69 @@ Setup steps:
119119
require'lspconfig'.tact.setup {}
120120
```
121121

122+
### Vim
123+
124+
Prerequisites:
125+
126+
- Vim 8 or newer
127+
- Async LSP Client for Vim: [vim-lsp](https://github.com/prabirshrestha/vim-lsp)
128+
- Plugin for Tact: [tact.vim](https://github.com/tact-lang/tact.vim)
129+
130+
Recommended, but not required:
131+
132+
- Auto-configurations for many language servers: [vim-lsp-settings](https://github.com/mattn/vim-lsp-settings)
133+
134+
Setup steps:
135+
136+
1. Install the [tact.vim](https://github.com/tact-lang/tact.vim) if it isn't already installed. Prefer using a non-builtin plugin manager to easily get new updates.
137+
138+
2. Install the [vim-lsp](https://github.com/prabirshrestha/vim-lsp) plugin if it isn't already installed. For that, use [vim-plug](https://github.com/junegunn/vim-plug) or the built-in package manager of Vim 8+, see [`:help packages`](https://vimhelp.org/repeat.txt.html#packages).
139+
140+
- If it wasn't installed before, you'll need to setup basic keybindings with the language client. Add the following to your `~/.vimrc` (or `~/_vimrc` if you're on Windows), or modify to your preferences:
141+
142+
```vim
143+
function! s:on_lsp_buffer_enabled() abort
144+
setlocal omnifunc=lsp#complete
145+
setlocal signcolumn=yes
146+
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
147+
nmap <buffer> gd <plug>(lsp-definition)
148+
nmap <buffer> gs <plug>(lsp-document-symbol-search)
149+
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
150+
nmap <buffer> gr <plug>(lsp-references)
151+
nmap <buffer> gi <plug>(lsp-implementation)
152+
nmap <buffer> gt <plug>(lsp-type-definition)
153+
nmap <buffer> <leader>rn <plug>(lsp-rename)
154+
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
155+
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
156+
nmap <buffer> K <plug>(lsp-hover)
157+
nnoremap <buffer> <expr><c-f> lsp#scroll(+4)
158+
nnoremap <buffer> <expr><c-d> lsp#scroll(-4)
159+
160+
let g:lsp_format_sync_timeout = 1000
161+
autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
162+
163+
" refer to doc to add more commands
164+
endfunction
165+
166+
augroup lsp_install
167+
au!
168+
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
169+
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
170+
augroup END
171+
```
172+
173+
3. Add the following to your `~/.vimrc` (or `~/_vimrc` if you're on Windows):
174+
175+
```vim
176+
if executable('node')
177+
au User lsp_setup call lsp#register_server({
178+
\ 'name': 'tact',
179+
\ 'cmd': {server_info->['node', '/absolute/path/to/language-server/dist/server.js', '--stdio']},
180+
\ 'allowlist': ['tact'],
181+
\ })
182+
endif
183+
```
184+
122185
### Sublime Text
123186

124187
1. Install [LSP](https://packagecontrol.io/packages/LSP) package:

0 commit comments

Comments
 (0)