All Projects → dvdsk → prosesitter.nvim

dvdsk / prosesitter.nvim

Licence: MIT License
A (work in progress) grammar, spelling and style plugin for Neovim

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to prosesitter.nvim

eslint-plugin-chai-friendly
Makes eslint friendly towards Chai.js 'expect' and 'should' statements.
Stars: ✭ 49 (+113.04%)
Mutual labels:  linting
comby-rust
Rust refactoring templates for comby, the structural find-and-replace tool.
Stars: ✭ 23 (+0%)
Mutual labels:  linting
prettier-check
Check that all files match prettier code style.
Stars: ✭ 54 (+134.78%)
Mutual labels:  linting
stylelint-config-xo
Stylelint shareable config for XO
Stars: ✭ 34 (+47.83%)
Mutual labels:  linting
vale-server
🖥️ A lightweight desktop app for Vale.
Stars: ✭ 32 (+39.13%)
Mutual labels:  vale
Microsoft
A Vale-compatible implementation of the Microsoft Writing Style Guide.
Stars: ✭ 56 (+143.48%)
Mutual labels:  vale
editorconfig-checker.javascript
A tool to verify that your files are in harmony with your .editorconfig
Stars: ✭ 59 (+156.52%)
Mutual labels:  linting
luacheck
A tool for linting and static analysis of Lua code.
Stars: ✭ 139 (+504.35%)
Mutual labels:  linting
makefiles
No description or website provided.
Stars: ✭ 23 (+0%)
Mutual labels:  linting
schreib-gut
German extension for write-good
Stars: ✭ 34 (+47.83%)
Mutual labels:  linting
li18nt
🌎 Lint your i18n translation files. Detect conflicting properties, duplicates and make it more readable and easier to maintain by formatting it!
Stars: ✭ 29 (+26.09%)
Mutual labels:  linting
eslint-plugin-import
ESLint plugin with rules that help validate proper imports.
Stars: ✭ 4,290 (+18552.17%)
Mutual labels:  linting
python
Python Style Guide
Stars: ✭ 49 (+113.04%)
Mutual labels:  linting
docker-go-dev
The containerized Go development environment.
Stars: ✭ 93 (+304.35%)
Mutual labels:  linting
ts-engine
Power TypeScript packages and reduce your config overhead.
Stars: ✭ 102 (+343.48%)
Mutual labels:  linting
Golite
Add essential language support for the Go language to Sublime Text 3.
Stars: ✭ 14 (-39.13%)
Mutual labels:  linting
flake8-html
Generate HTML reports of flake8 violations
Stars: ✭ 40 (+73.91%)
Mutual labels:  linting
React-Native-Web-TypeScript-Prettier-Boilerplate
A starterkit to work with nextjs, react-native, storybook… all with prettified typescript and in a monorepo
Stars: ✭ 16 (-30.43%)
Mutual labels:  linting
laravel-prose-linter
Syntax-aware proofreading for your Laravel application.
Stars: ✭ 91 (+295.65%)
Mutual labels:  vale
aegir
AEgir - Automated JavaScript project building
Stars: ✭ 73 (+217.39%)
Mutual labels:  linting

prosesitter

Prosesitter uses treesitter and vale to bring true syntax aware prose linting to neovim. While it is reasonably feature complete it still needs a lot of stability work. There is a list of great alternative the end of the readme if you are looking for something right now.

What is Prosesitter?

prosesitter.nvim is a text linting tool that adds grammar, spell and style checking to your comments and strings. It uses language tool and vale as backends to check what you write for problems. Style issues can vary using the passive voice, weasle words ('very' unique) to using noninclusive terms. You set your own style or use an existing one. Prosesitter will offer to setup a self contained install of language tool and vale including some defaults styles from the vales style libary.

asciicast

Features

  • Low performance impact; backends are called asynchronously and only when needed with only the text that changed.
  • Portable; written in lua and depends only on the backends, offers to install them if not found.
  • Configurable; specify exactly what you want to lint for which language, switch between prose style without reloading.
  • Can supports any language with a treesitter parser; (you might need to add your own query if I have not yet added one adding queries). Out of the box support for: latex, bash, lua, python, rust, c, and c++.
  • Telescope integration.

Requirements

  • neovim > 0.6
  • treesitter set up
  • (windows only) vale installed

Installation

packer.nvim:

use {
	'dvdsk/prosesitter'
}

vim-plug:

plug 'dvdsk/prosesitter'

Setup

require("telescope").load_extension("prosesitter") -- Optionally, depends on telescope.nvim
require("prosesitter"):setup()

or pass a (partial)configuration; setting up your own vale binary, vale config and or adding extra treesitter queries (see adding queries)

require("telescope").load_extension("prosesitter") -- Optionally, depends on telescope.nvim
require("prosesitter"):setup({
	vale_bin = vim.fn.stdpath("data") .. "/prosesitter/vale",
	vale_cfg = vim.fn.stdpath("data") .. "/prosesitter/vale_cfg.ini",
	-- override default behaviour for a languag
	ext = {
		py = {
			queries = {
				strings = "[(string) ] @capture",
				comments = "[(comment)+ ] @capture",
			},
			lint_target = "both",
			disabled = false,
		},
		tex = {
			lint_target = "strings",
			disabled = false,
		},
		sh = {
			lint_target = "comments",
		},
	},
	-- highlight groups to use for lint errors, warnings and suggestions
	severity_to_hl = { error = "SpellBad", warning = "SpellRare", suggestion = "SpellCap" },
	auto_enable = true, -- do not start linting files on open (default = true)
	default_cmds = false, -- do not add commands (default = true)
})

Usage

You can map/use either lua functions or commands, the following functions are availible:

  • next/prev: jump to the next/prev linting issue from the current cursor pos and show the error in a popup window
  • popup: show a popup window if there is a linting issue on the current cursor pos
  • disable: disables linting on change removing all added highlights
  • enable: re-enable linting on change and lint all open (supported) buffers
  • switch_vale_cfg: switches to a different vale config, updates all highlights to reflect the change. Not availible as command, takes as argument the path to the vale config to use

The functions next, prev and popup return a bool that is true if they could jump/open a popup window. Use this (for example) to create a single keymap for prosesitters popup and your lsps show documentation function.

The commands:

  • PsNext
  • PsPrev
  • PsPopup
  • PsEnable
  • PsDisable

example mapping:

Unfortunatly I have not yet found good keybindings to suggest as I have a rather excentric config.

Setting up a simple keybinding

local opt = { noremap = true, silent = true, nowait = true }
vim.api.nvim_set_keymap("n", ",", "lua require('prosesitter').next()", opt)

A more complicated example:

-- if there was a linting error on the current cursor
-- position open a popup, otherwise show the lsp hover 
-- documentation
function Hover()
	if not require('prosesitter').popup() then
		vim.lsp.buf.hover()
	end
end

local cmd = ":lua Hover()<CR>"
local opt = { noremap = true, silent = true, nowait = true }
vim.api.nvim_set_keymap("n", ",", cmd, opt)

User command

You might not want to switch style too often, thus command can be more suitable then a keybind. You can set one up like this:

vim.cmd(':command EmailStyle lua require("prosesitter").switch_vale_cfg("~/Documents/vale_mail.ini")')

Future work

In no paticular order I would like to add the following features:

  • ability to hide a specific error
  • support for more queries (PR's are welcome!)
  • allow easy switching between linting comments, strings and comments and strings
  • making linting strings more practical by filtering out urls and paths
  • function to try and automatically fix an issue

Trouble shooting

  • Do you have a treesitter parser installed for the file you want to prose lint? Try installing one with TSInstall <tab to autocomplete>.
  • If the treesitter parser is crashing it can help to update it to the latest version with TSInstall update
  • No linting is done on a .tex file. It could be that vim has decided the file does not contain LaTeX. You can force vim to treat .tex files as LaTeX by setting vim.g.tex_flavor = "latex" in your init.lua.

Related work

If you like this plugin you might also be intrested in:

  • ltex, a language server for latex and markdown with spell and grammar checking build in using languagetool. A great alternative for this plugin if you want to have spell and grammar checking for latex and markdown in vim. Use together with grammar-guard.nvim.
  • spellsitter, the inspiration for this plugin and a great alternative if you are just looking for spellchecking comments
  • ale a asynchronous linting plugin that leaves syntax handling to the linters. Supports the default syntax vale supports (Markdown, AsciiDoc, reStructuredText, HTML, XML).
  • vim-language collects all grammer mistakes into the quickfix list
  • vim-grammarous grammar checker automatically downloads and sets up LanguageTool.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].