Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/FuelLabs/sway.vim
Vim syntax file for Sway.
https://github.com/FuelLabs/sway.vim
Last synced: 3 months ago
JSON representation
Vim syntax file for Sway.
- Host: GitHub
- URL: https://github.com/FuelLabs/sway.vim
- Owner: FuelLabs
- License: apache-2.0
- Created: 2021-11-11T21:15:22.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-29T20:59:07.000Z (4 months ago)
- Last Synced: 2024-04-02T17:06:34.123Z (3 months ago)
- Language: Vim Script
- Homepage:
- Size: 17.6 KB
- Stars: 14
- Watchers: 20
- Forks: 9
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-sway - sway.vim - vim syntax (Editor Plugins)
README
## About
Vim syntax file for Sway
## Installation
Pre-requisites:
1. Clone this repo
1. Ensure you have the `forc-lsp` binary with `which forc-lsp`. If not, install [the Sway toolchain](https://fuellabs.github.io/sway/v0.25.2/introduction/installation.html).### Neovim
1. Copy the folders 'ftdetect' and 'syntax' to the config folder:
```
cp -R ~/sway.vim/syntax ~/.config/nvim && cp -R ~/sway.vim/ftdetect ~/.config/nvim
```
2. If you do not have `~/.config/nvim/init.lua`, install [kickstart.nvim](https://github.com/nvim-lua/kickstart.nvim).
3. If you already have `init.lua`, you may need to require extra dependencies, or simply copy [this block](https://github.com/nvim-lua/kickstart.nvim/blob/38828dcaf7c140902fedeaa75b017bf968400bb0/init.lua#L401-L604).
4. Add the following to `~/.config/nvim/init.lua`:
```
-- Install Sway LSP as a custom server
local lspconfig = require 'lspconfig'
local configs = require 'lspconfig.configs'-- Check if the config is already defined (useful when reloading this file)
if not configs.sway_lsp then
configs.sway_lsp = {
default_config = {
cmd = {'forc-lsp'},
filetypes = {'sway'},
on_attach = on_attach,
init_options = {
-- Any initialization options
logging = { level = 'trace' }
},
root_dir = function(fname)
return lspconfig.util.find_git_ancestor(fname)
end;
settings = {};
};
}
endlspconfig.sway_lsp.setup{}
```
4. Check that the LSP is running by running `:LspInfo` and trying out features like Goto Definition (`gd`) and Hover (`K`). The key mappings are defined in `~/.config/nvim/init.lua`![Nov-10-2022 20-18-51](https://user-images.githubusercontent.com/47993817/201267485-dcff3e58-1b13-4215-9c77-c262f8bebdc5.gif)
### Vim
1. Clone this repo
2. Copy the folders 'ftdetect' and 'syntax' to the config folder:
```
cp -R ~/sway.vim/syntax ~/.vim && cp -R ~/sway.vim/ftdetect ~/.vim
```
3. Edit your `~/.vim/filetype.vim` to contain the following block:
```
if exists("did_load_filetypes")
finish
endifaugroup filetypedetect
au! BufNewFile,BufRead *.[sS][wW] setf sway
augroup END
```
4. Install [plug.vim](https://github.com/junegunn/vim-plug)
5. Add the following to your `~/.vimrc`
```
call plug#begin()Plug 'prabirshrestha/vim-lsp'
call plug#end()
```
6. Create a file called `~/.vim/lsp.vim` with the following contents, or add this to an existing vim script:
```
" vim-lsp for Sway (sway-lsp)
if executable('sway-lsp')
au User lsp_setup call lsp#register_server({
\ 'name': 'sway-lsp',
\ 'cmd': {server_info->['sway-lsp']},
\ 'whitelist': ['sway'],
\ })
endif
```
7. Open vim and `:source ~/.vim/lsp.vim`
8. Check that the LSP is running with `:LspStatus` and try out feature like `:LspDefinition` and `:LspHover`. The full list of commands are defined [here](https://github.com/prabirshrestha/vim-lsp).![Nov-10-2022 21-05-18](https://user-images.githubusercontent.com/47993817/201267452-4b51a037-6b49-464c-92c4-c0df50c15fd4.gif)