irongit

filetype configs with named files. has telescope

added readme

huncholanehuncholaneauthored
parent 7fecad4commit 3ab097f97fb7bbcb2eb9c6d2ec26255f2d73f42bBrowse files

1 file changed, +170 -0

+170-0README.md
@@ -0,0 +1,170 @@
1+# ftconfig.nvim
2+
3+A Neovim plugin for managing per-filetype configuration with ease. Configure indentation, formatters, and other filetype-specific settings in individual Lua files.
4+
5+## Features
6+
7+- **Per-filetype configuration**: Create separate config files for each filetype
8+- **Automatic indentation**: Set custom indentation per filetype (shiftwidth, tabstop, softtabstop)
9+- **Conform.nvim integration**: Configure formatters per filetype
10+- **Easy editing**: Quick commands and Telescope integration for editing configs
11+- **Auto-completion**: Filetype completion for commands
12+
13+## Installation
14+
15+### lazy.nvim
16+```lua
17+{
18+ "huncholane/ftconfig.nvim",
19+ dependencies = {
20+ "telescope.nvim", -- optional, for telescope integration
21+ "conform.nvim", -- optional, for formatter integration
22+ },
23+ config = function()
24+ require("ftconfig").setup()
25+ end,
26+}
27+```
28+
29+### packer.nvim
30+```lua
31+use {
32+ "huncholane/ftconfig.nvim",
33+ requires = {
34+ "nvim-telescope/telescope.nvim", -- optional
35+ "stevearc/conform.nvim", -- optional
36+ },
37+ config = function()
38+ require("ftconfig").setup()
39+ end,
40+}
41+```
42+
43+## Usage
44+
45+### Commands
46+
47+- `:FT [filetype]` - Edit or create config for the specified filetype
48+- `:FT` - Edit config for the current buffer's filetype
49+
50+### Telescope Extension
51+
52+Load the telescope extension:
53+```lua
54+require("telescope").load_extension("ftconfig")
55+```
56+
57+Then use:
58+- `:Telescope ftconfig` - Browse and select filetypes to configure
59+
60+The picker shows:
61+- 󰓎 Current buffer's filetype (prioritized)
62+- 📝 Filetypes with existing configs
63+- 󰙴 Other available filetypes
64+
65+## Configuration
66+
67+Filetype configs are stored in `~/.config/nvim/lua/ftconfig/` as individual `.lua` files.
68+
69+### Example Filetype Config
70+
71+Create `~/.config/nvim/lua/ftconfig/javascript.lua`:
72+
73+```lua
74+---@type FTSpec
75+return {
76+ -- Set indentation to 2 spaces
77+ indent = 2,
78+
79+ -- Configure formatters via conform.nvim
80+ conform = {
81+ use = { "prettier", "eslint_d" },
82+ formatters = {
83+ prettier = {
84+ prepend_args = { "--tab-width", "2" }
85+ }
86+ }
87+ },
88+
89+ -- LSP configuration (placeholder for future features)
90+ lsp = {
91+ -- Reserved for future LSP integration
92+ }
93+}
94+```
95+
96+### Configuration Schema
97+
98+```lua
99+---@class FTSpec
100+---@field indent? integer -- Indentation size (default: 4)
101+---@field conform? FTConformSpec -- Conform.nvim configuration
102+---@field lsp? table<LSPName, any> -- LSP configuration (reserved)
103+
104+---@class FTConformSpec
105+---@field use string[] -- List of formatters to use
106+---@field formatters? table<string, conform.FileFormatterConfig> -- Formatter-specific config
107+```
108+
109+## Examples
110+
111+### Python with Black formatting
112+`~/.config/nvim/lua/ftconfig/python.lua`:
113+```lua
114+return {
115+ indent = 4,
116+ conform = {
117+ use = { "black", "isort" },
118+ formatters = {
119+ black = {
120+ prepend_args = { "--line-length", "88" }
121+ }
122+ }
123+ }
124+}
125+```
126+
127+### Go with gofmt
128+`~/.config/nvim/lua/ftconfig/go.lua`:
129+```lua
130+return {
131+ indent = 4,
132+ conform = {
133+ use = { "gofmt", "goimports" }
134+ }
135+}
136+```
137+
138+### Lua with stylua
139+`~/.config/nvim/lua/ftconfig/lua.lua`:
140+```lua
141+return {
142+ indent = 2,
143+ conform = {
144+ use = { "stylua" },
145+ formatters = {
146+ stylua = {
147+ prepend_args = { "--indent-type", "Spaces", "--indent-width", "2" }
148+ }
149+ }
150+ }
151+}
152+```
153+
154+## How It Works
155+
156+1. On setup, the plugin scans `~/.config/nvim/lua/ftconfig/` for `.lua` files
157+2. Each file is loaded as a filetype configuration
158+3. FileType autocmds are created to apply indentation settings
159+4. Conform.nvim is configured with the specified formatters
160+5. The `:FT` command and Telescope extension provide easy access to edit configs
161+
162+## Requirements
163+
164+- Neovim >= 0.7.0
165+- Optional: [conform.nvim](https://github.com/stevearc/conform.nvim) for formatter integration
166+- Optional: [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) for the picker interface
167+
168+## License
169+
170+MIT