-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from alerque/nvim-plugin
- Loading branch information
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
rockspec_format = "3.0" | ||
package = "@[email protected]" | ||
version = "@SEMVER@-@ROCKREV@" | ||
|
||
source = { | ||
url = "git+https://github.com/alerque/decasify.git", | ||
tag = "@TAG@" | ||
} | ||
|
||
description = { | ||
summary = "NeoVIM plugin wrapping decasify crate to cast strings to title-case according to locale specific style guides including Turkish support", | ||
detailed = [[ | ||
A NeoVIM plugin for | ||
Provides casing functions for long strings (not just individual words) | ||
supporting the grammatical style guides of various locales including Turkish. | ||
]], | ||
license = "LGPL-3.0-only", | ||
homepage = "https://github.com/alerque/decasify", | ||
issues_url = "https://github.com/alerque/decasify/issues", | ||
maintainer = "Caleb Maclennan <[email protected]>", | ||
labels = { "i18n" } | ||
} | ||
|
||
dependencies = { | ||
"lua >= 5.1", | ||
"decasify" == version | ||
} | ||
|
||
build = { | ||
type = "builtin", | ||
copy_directories = { | ||
"plugin", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
if vim.g.loaded_decasify then | ||
return | ||
end | ||
|
||
local decasify = require("decasify") | ||
|
||
vim.api.nvim_create_user_command("Decasify", function (args) | ||
local case = args.fargs[1] or vim.b.decasify_case or vim.g.decasify_case or "title" | ||
local locale = vim.b.decasify_case or vim.g.decasify_locale or "en" | ||
local style = vim.b.decasify_case or vim.g.decasify_style or "gruber" | ||
local first, last = args.line1, args.line2 | ||
local caser = case:gsub("case$", "") .. "case" | ||
if type(decasify[caser]) ~= "function" then | ||
vim.notify(("Decasify doesn't know what case '%s' is."):format(caser)) | ||
return false | ||
end | ||
local lines = vim.api.nvim_buf_get_lines(0, first - 1, last, true) | ||
for i, line in ipairs(lines) do | ||
lines[i] = decasify[caser](line, locale, locale == "en" and style) | ||
end | ||
vim.api.nvim_buf_set_lines(0, first - 1, last, true, lines) | ||
end, { desc = "Pass lines to decasify for recasing prose", nargs = "*", range = true }) | ||
|
||
vim.g.loaded_decasify = true |