Skip to content

Commit

Permalink
🔥 Remove completion for sublime-syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Jun 17, 2023
1 parent f931560 commit 1863786
Show file tree
Hide file tree
Showing 13 changed files with 320 additions and 226 deletions.
42 changes: 15 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
exclude: ^assets/json/.*\.json$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: fix-byte-order-marker
Expand All @@ -11,7 +12,6 @@ repos:
- id: trailing-whitespace
- id: mixed-line-ending
- id: end-of-file-fixer
exclude: ^assets/json/.*\.json$
- id: detect-private-key
- id: check-symlinks
- id: check-ast
Expand All @@ -22,66 +22,62 @@ repos:
- id: check-toml
- id: check-json
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.3.1
rev: v1.5.1
hooks:
- id: remove-crlf
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.4
hooks:
- id: codespell
additional_dependencies:
- tomli
- repo: https://github.com/jorisroovers/gitlint
rev: v0.17.0
rev: v0.19.1
hooks:
- id: gitlint
args:
- --msg-filename
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.6.1
rev: 2.7.1
hooks:
- id: editorconfig-checker
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: check-mailmap
- repo: https://github.com/adrienverge/yamllint
rev: v1.28.0
rev: v1.32.0
hooks:
- id: yamllint
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
- id: mdformat
args:
- --number
additional_dependencies:
- mdformat-pyproject
- mdformat-gfm
- mdformat-myst
- mdformat-tables
- mdformat-toc
- mdformat-footnote
- mdformat-frontmatter
- mdformat-deflist
- mdformat-beautysh
- mdformat-black
- mdformat-config
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.5.1
rev: v0.7.1
hooks:
- id: markdownlint-cli2
additional_dependencies:
- [email protected]
- repo: https://github.com/kumaraditya303/mirrors-pyright
rev: v1.1.277
hooks:
- id: pyright
- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
rev: 6.3.0
hooks:
- id: pydocstyle
additional_dependencies:
- toml
- tomli
- repo: https://github.com/kumaraditya303/mirrors-pyright
rev: v1.1.310
hooks:
- id: pyright
- repo: https://github.com/vimjas/vint
rev: v0.4a4
hooks:
Expand All @@ -90,11 +86,3 @@ repos:
rev: v0.7.1
hooks:
- id: vimdoc
- repo: https://github.com/Freed-Wu/pre-commit-make
rev: 0.0.1
hooks:
- id: make

ci:
skip:
- make
21 changes: 0 additions & 21 deletions Makefile

This file was deleted.

107 changes: 53 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,46 @@
Vim filetype plugin for:

- [sublime-syntax](http://www.sublimetext.com/docs/syntax.html)
- [syntax-test](http://www.sublimetext.com/docs/syntax.html#testing)

![Screenshot](https://user-images.githubusercontent.com/32936898/194713936-8ea3403f-8133-4c75-876f-9d68bc145123.png)
- [syntax-test](http://www.sublimetext.com/docs/syntax.html#testing)

- [x] ftplugin: commentstring, etc

- [x] compilers: bat, syntest

- [x] syntax highlight, include incorrect header
- [x] completion
- [x] linter
- [ ] document hover
- [ ] LSP

- [ ] support [tmLanguage](https://macromates.com/manual/en/language_grammars)

<!-- mdformat-toc start --slug=github --no-anchors --maxlevel=6 --minlevel=2 -->
- [x] LSP

- [x] linter
- [x] completion
- [ ] document hover

## Compilers

Install

- [syntest](https://github.com/trishume/syntect) for `syntax_test_*`
- [bat](https://github.com/sharkdp/bat) for `*.sublime-syntax`

### syntest

#### Build From Source

```sh
git clone --depth=1 https://github.com/trishume/syntect
cd syntect
cargo build --release --example syntest
sudo install -D target/release/examples/syntest -t /usr/local/bin
```

- [Syntax Highlight](#syntax-highlight)
- [Completion](#completion)
- [Linter](#linter)
- [Install syntest](#install-syntest)
- [Build From Source](#build-from-source)
- [For Archlinux](#for-archlinux)
- [Other Install Methods](#other-install-methods)
- [License](#license)
#### For Archlinux

<!-- mdformat-toc end -->
```sh
yay -S syntest
```

## Syntax Highlight

Expand All @@ -70,56 +86,39 @@ Note `watch` should be `match` and `strings` should be `string`:

![Keyword](https://user-images.githubusercontent.com/32936898/195125476-59f056e1-7001-4aa9-b2ba-62a8fd0e0d2e.png)

## Completion
## Linter

Completion needs [coc.nvim](https://github.com/neoclide/coc.nvim). Now it can
complete scope names and sublime syntax file's keywords. Generate completion
cache needs [some python library](requirements.txt). If you don't want to
install python, you can use generated completion cache:
![Screenshot](https://user-images.githubusercontent.com/32936898/194713936-8ea3403f-8133-4c75-876f-9d68bc145123.png)

```vim
:echo g:sublime_syntax#cache_dir
# usually be ~/.cache/nvim/sublime_syntax.vim
```
Install [coc-diagnostic](https://github.com/iamcco/coc-diagnostic) and syntest:

```sh
install assets/json/*.json -Dt ~/.cache/nvim/sublime_syntax.vim
```json
{
"diagnostic-languageserver": {
"filetypes": {
"syntax_test": "syntest"
}
}
}
```

A more intelligent completion needs LSP, which is a TODO.
## Completion

![Completion](https://user-images.githubusercontent.com/32936898/195147969-93486f40-9c8a-4b79-841b-e2c8dd0b2766.png)

## Linter

For sublime syntax files, make needs [bat](https://github.com/sharkdp/bat).
Linter needs [coc-yaml](https://github.com/neoclide/coc-yaml).

For syntax test files, `:make` needs [syntest](https://github.com/trishume/syntect).
Linter needs [coc-diagnostic](https://github.com/iamcco/coc-diagnostic/pull/136).

### Install syntest

#### Build From Source
Install [coc-yaml](https://github.com/neoclide/coc-yaml):

```sh
git clone --depth=1 https://github.com/trishume/syntect
cd syntect
cargo build --release --example syntest
sudo install -D target/release/examples/syntest -t /usr/local/bin
```

#### For Archlinux

```sh
yay -S syntest
```json
{
"yaml.schemas": {
"/the/path/of/sublime-syntax.vim/sublime-syntax.json": "*.sublime-syntax"
}
}
```

#### Other Install Methods
## More usages

- [ ] Windows (Msys2)
- [ ] Android (Termux)
- [ ] Linux/macOS (Homebrew)
[`:help sublime-syntax`](doc/sublime-syntax.txt)

## License

Expand Down
1 change: 0 additions & 1 deletion assets/json/syntax.json

This file was deleted.

2 changes: 1 addition & 1 deletion autoload/coc/source/sublime_syntax.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function! coc#source#sublime_syntax#complete(opt, cb) abort
\ && a:opt.line =~# '\v^\s*\V' . b:syntax_test_comment . '\v\s*%(\^+|\<-)'
let l:items += g:sublime_syntax#scope_items
endif
if a:opt.filetype ==# 'yaml'
if expand('%:e') ==# 'sublime_syntax'
let l:items += g:sublime_syntax#syntax_items
if a:opt.line =~# '\v^ *-? %(%(meta_)?scope|\d): '
let l:items += g:sublime_syntax#scope_items
Expand Down
22 changes: 1 addition & 21 deletions autoload/sublime_syntax.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,10 @@
" Note: if you use |indentLine|, remember: >
" let g:indentLine_fileTypeExclude = ['syntax_test']
" <
" If you use |coc-diagnostic|, remember: >
" {
" "diagnostic-languageserver": {
" "filetypes": {
" "syntax_test": "syntest"
" }
" }
" }
" <
" If you use |coc-nvim|, remember: >
" let g:coc_filetype_map = {
" \ 'sublime_syntax': 'yaml',
" \ }
" <
" If you use |nvim-treesitter|, remember: >
" -- https://github.com/nvim-treesitter/nvim-treesitter#adding-parsers
" local ft_to_parser = \
" require"nvim-treesitter.parsers".filetype_to_parsername
" ft_to_parser.sublime_syntax = "yaml"
" <

let s:path = fnamemodify(resolve(expand('<sfile>:p')), ':h:h')
let s:cache_dir = s:path . '/assets/json'
for s:cache_name in ['scope', 'syntax']
for s:cache_name in ['scope']
let s:cache = s:cache_dir . '/' . s:cache_name . '.json'
let s:{s:cache_name}_items = json_decode(join(readfile(s:cache), ''))
endfor
Expand Down
23 changes: 0 additions & 23 deletions doc/sublime-syntax.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,6 @@ Note: if you use |indentLine|, remember:
>
let g:indentLine_fileTypeExclude = ['syntax_test']
<
If you use |coc-diagnostic|, remember:
>
{
"diagnostic-languageserver": {
"filetypes": {
"syntax_test": "syntest"
}
}
}
<
If you use |coc-nvim|, remember:
>
let g:coc_filetype_map = {
\ 'sublime_syntax': 'yaml',
\ }
<
If you use |nvim-treesitter|, remember:
>
-- https://github.com/nvim-treesitter/nvim-treesitter#adding-parsers
local ft_to_parser = \
require"nvim-treesitter.parsers".filetype_to_parsername
ft_to_parser.sublime_syntax = "yaml"
<

==============================================================================
CONFIGURATION *sublime-syntax-config*
Expand Down
1 change: 0 additions & 1 deletion ftdetect/sublime_syntax.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
augroup sublime_syntax
autocmd!
autocmd BufNewFile,BufRead syntax_test_* call syntax_test#init()
autocmd BufNewFile,BufRead *.sublime-syntax setfiletype sublime_syntax
augroup END
15 changes: 0 additions & 15 deletions ftplugin/sublime_syntax.vim

This file was deleted.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.mdformat]
number = true
Loading

0 comments on commit 1863786

Please sign in to comment.