Full Code of nullchilly/fsread.nvim for AI

main a637bf048f73 cached
3 files
3.8 KB
1.3k tokens
1 requests
Download .txt
Repository: nullchilly/fsread.nvim
Branch: main
Commit: a637bf048f73
Files: 3
Total size: 3.8 KB

Directory structure:
gitextract_c87fxjjs/

├── .github/
│   └── README.md
├── LICENSE
└── plugin/
    └── fsread.lua

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/README.md
================================================
# fsread.nvim

Flow state reading in neovim

https://user-images.githubusercontent.com/56817415/203623326-b12af198-e1ec-49d2-a170-c314241a8864.mp4

## Installation

```lua
use "nullchilly/fsread.nvim"
```

## Usage

```vim
:FSRead " Flow state visual range
:FSClear " Clear all flow states
:FSToggle " Toggle flow state
```

## Config

```lua
vim.g.flow_strength = 0.7 -- low: 0.3, middle: 0.5, high: 0.7 (default)
vim.api.nvim_set_hl(0, "FSPrefix", { fg = "#cdd6f4" })
vim.api.nvim_set_hl(0, "FSSuffix", { fg = "#6C7086" })
```

## Thanks to

[thatvegandev/fsrx](https://github.com/thatvegandev/fsrx)
[bionic-reading.com](https://bionic-reading.com/)


================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2022 Null Chilly

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: plugin/fsread.lua
================================================
local M = { on = false }
local ns_id = vim.api.nvim_create_namespace("fsread")

vim.g.flow_strength = vim.g.flow_strength or 0.7

function M.create(opts)
	M.on = true

	local line_start = 0
	local line_end = vim.api.nvim_buf_line_count(0)
	if opts and opts.range == 2 then -- Use visual range
		line_start = vim.api.nvim_buf_get_mark(0, "<")[1] - 1
		line_end = vim.api.nvim_buf_get_mark(0, ">")[1]
	end

	local lines = vim.api.nvim_buf_get_lines(0, line_start, line_end, true)
	local i = line_start - 1
	for _, line in pairs(lines) do
		local len = #line
		i = i + 1
		vim.api.nvim_buf_set_extmark(0, ns_id, i, 0, {
			hl_group = "FSSuffix",
			end_col = len,
		})
		local st = nil
		for j = 1, len do
			local cur = string.sub(line, j, j)
			local re = cur:match("[%w']+")
			if st then
				if j == len then
					if re then
						j = j + 1
						re = nil
					end
				end
				if not re then
					local en = j - 1
					vim.api.nvim_buf_set_extmark(0, ns_id, i, st - 1, {
						hl_group = "FSPrefix",
						end_col = math.floor(st + math.min((en - st) / 2, (en - st) * vim.g.flow_strength)),
					})
					st = nil
				end
			elseif re then
				st = j
			end
		end
	end
end

function M.clear()
	M.on = false
	vim.api.nvim_buf_clear_namespace(0, ns_id, 0, -1)
	ns_id = vim.api.nvim_create_namespace("fsread")
end

function M.toggle(opts)
	M.on = not M.on
	if M.on then
		M.create(opts)
	else
		M.clear()
	end
end

vim.api.nvim_create_user_command("FSRead", function(opts)
	M.create(opts)
end, {
	range = 2,
})

vim.api.nvim_create_user_command("FSClear", function()
	M.clear()
end, {
	range = 2,
})

vim.api.nvim_create_user_command("FSToggle", function(opts)
	M.toggle(opts)
end, {
	range = 2,
})

function M.highlight()
	if vim.o.background == "dark" then
		vim.api.nvim_set_hl(0, "FSPrefix", { default = true, fg = "#cdd6f4" })
		vim.api.nvim_set_hl(0, "FSSuffix", { default = true, fg = "#6C7086" })
	else
		vim.api.nvim_set_hl(0, "FSPrefix", { default = true, fg = "#000000", bold = true })
		vim.api.nvim_set_hl(0, "FSSuffix", { default = true, fg = "#4C4F69" })
	end
end

M.highlight()

vim.api.nvim_create_autocmd("ColorScheme", {
	pattern = "*",
	callback = function()
		M.highlight()
	end,
})
Download .txt
gitextract_c87fxjjs/

├── .github/
│   └── README.md
├── LICENSE
└── plugin/
    └── fsread.lua
Condensed preview — 3 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (4K chars).
[
  {
    "path": ".github/README.md",
    "chars": 652,
    "preview": "# fsread.nvim\n\nFlow state reading in neovim\n\nhttps://user-images.githubusercontent.com/56817415/203623326-b12af198-e1ec-"
  },
  {
    "path": "LICENSE",
    "chars": 1068,
    "preview": "MIT License\n\nCopyright (c) 2022 Null Chilly\n\nPermission is hereby granted, free of charge, to any person obtaining a cop"
  },
  {
    "path": "plugin/fsread.lua",
    "chars": 2201,
    "preview": "local M = { on = false }\nlocal ns_id = vim.api.nvim_create_namespace(\"fsread\")\n\nvim.g.flow_strength = vim.g.flow_strengt"
  }
]

About this extraction

This page contains the full source code of the nullchilly/fsread.nvim GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 3 files (3.8 KB), approximately 1.3k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!