Crates.io | natural_syntax_ls |
lib.rs | natural_syntax_ls |
version | 0.0.1 |
source | src |
created_at | 2024-07-11 15:11:15.441457 |
updated_at | 2024-07-12 09:41:02.772688 |
description | Natural language syntax highlighting. |
homepage | |
repository | https://github.com/SichangHe/natural_syntax |
max_upload_size | |
id | 1299664 |
size | 145,884 |
Natural-Syntax-LS is a language server that highlights different parts of speech (POS) in plain text.
Download libtorch
v2.1 as per
Rust-BERT's documentation.
You can figure out the URL to download libtorch
in tch-rs' build
script.
The LIBTORCH
variable should be the torch/
directory.
Rust-BERT has an "automatic installation" option that
uses tch-rs' build script to download libtorch
.
However,
the binary produced this way does not run because that libtorch
is not on
LD_LIBRARY_PATH
.
Alternatively, you could statically link libtorch
,
but that would
require you to download libtorch
yourself anyway.
Install the natural_syntax_ls
package with Cargo or friends to
get the natural-syntax-ls
binary:
cargo install natural_syntax_ls --default-features=false
Setting the default-features
to
false
disables downloading libtorch
(automatic installation).
Because otherwise it would be a pain to run the continuous integration.
Please paste the below natural_syntax_ls_setup
function in
your Nvim configuration and call it with your client's capabilities
.
Please see my config for an
example.
natural_syntax_ls_setup
function.local function natural_syntax_ls_setup(capabilities)
local lspconfig = require('lspconfig')
require('lspconfig.configs')['natural_syntax_ls'] = {
default_config = {
cmd = { 'natural-syntax-ls' },
filetypes = { 'text' },
single_file_support = true,
},
docs = {
description = [[The Natural Syntax Language Server for highlighting parts of speech.]],
},
}
lspconfig['natural_syntax_ls'].setup {
capabilities,
init_options = {
token_map_update = {
-- Customize your POS-token mapping here. E.g.:
--[[
-- Disable coordinating conjunctions highlighting.
CC = vim.NIL, -- `nil` does not work because it gets ignored.
-- Highlight wh-determiners as enum members without any modifiers.
WDT = { type = "enumMember" },
-- Highlight determiners as read-only classes.
DT = { type = "class", modifiers = { "readonly" } },
]]
},
},
}
end
Customizations:
filetypes
field to text
,
but you can enable natural-syntax-ls for any other file types as well.
Note that, though,
the language server's semantic tokens supersede Tree-sitter highlighting by
default.token_map_update
field in init_options
,
you can customize the mapping between parts of speech and semantic tokens.
pos2token_bits
function in
semantic_tokens.rs
.PartOfSpeech
enum in
lib.rs
.TokenType
and
TokenModifier
in semantic_tokens.rs
,
all in camelCase.I do not currently use VSCode and these other editors, so I do not wish to maintain plugins for them.
However, it should be straightforward to implement plugins for them since Natural-Syntax-LS implements the Language Server Protocol (LSP). So, please feel free to make a plugin yourself and create an issue for me to link it here.
For a single document, only one prediction is scheduled at a time. When a prediction is ongoing, new updates are queued and the latest update replaces any previous updates queued.
We use tracing-subscriber
with the env-filter
feature to
emit logs1.
Please configure the log level by setting the RUST_LOG
environment variable.
On macOS, you may need to set DYLD_LIBRARY_PATH
to run the tests.