|
1 | | -*sqlformat.txt* SQL Formatting Plugin for Neovim |
2 | | - |
3 | | -Overview~ |
4 | | -SQLFormat is a Neovim plugin that formats SQL code using the sqlparse Python library. |
5 | | - |
6 | | -Installation~ |
7 | | -1. Install the plugin using your favorite plugin manager, e.g.: |
8 | | - Using vim-plug: |
9 | | - `Plug 'username/nvim-sqlformat'` |
10 | | -2. Ensure Python3 and sqlparse are installed: |
11 | | - `pip install sqlparse` |
12 | | - |
13 | | -Usage~ |
14 | | -- Format the entire buffer: `:SQLFormat` |
15 | | -- Format a range: `:'<,'>SQLFormat` |
16 | | -- Default keybinding: `<leader>sf` (normal mode) |
17 | | - |
18 | | -Configuration~ |
19 | | -- `g:sqlformat_indent`: Set indentation width (default: 2) |
20 | | -- `g:sqlformat_keyword_case`: Set keyword case ('upper', 'lower', or '' for none; default: 'upper') |
21 | | - |
22 | | -Example~ |
23 | | -let g:sqlformat_indent = 4 |
24 | | -let g:sqlformat_keyword_case = 'lower' |
| 1 | +*sqlformat.txt* SQL formatting plugin for Neovim |
| 2 | + |
| 3 | +============================================================================== |
| 4 | +INTRODUCTION *sqlformat-intro* |
| 5 | + |
| 6 | +nvim-sqlformat is a Neovim plugin that provides SQL code formatting using the |
| 7 | +sqlparse library. It offers customizable formatting options and integrates |
| 8 | +seamlessly with Neovim. |
| 9 | + |
| 10 | +============================================================================== |
| 11 | +INSTALLATION *sqlformat-installation* |
| 12 | + |
| 13 | +Using lazy.nvim: |
| 14 | +```lua |
| 15 | +{ |
| 16 | + 'andevgo/nvim-sqlformat', |
| 17 | + config = function() |
| 18 | + require('sqlformat').setup({ |
| 19 | + indent = 2, |
| 20 | + keyword_case = 'upper', |
| 21 | + line_width = 80, |
| 22 | + format_on_save = false, |
| 23 | + custom_keymaps = { |
| 24 | + format = '<leader>sf' |
| 25 | + } |
| 26 | + }) |
| 27 | + end |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +============================================================================== |
| 32 | +USAGE *sqlformat-usage* |
| 33 | + |
| 34 | +Commands: |
| 35 | + :SQLFormat Format the entire buffer |
| 36 | + :'<,'>SQLFormat Format selected lines in visual mode |
| 37 | + |
| 38 | +Keybindings: |
| 39 | + <leader>sf Format the current buffer (default) |
| 40 | + |
| 41 | +============================================================================== |
| 42 | +CONFIGURATION *sqlformat-configuration* |
| 43 | + |
| 44 | +The plugin can be configured through the setup function: |
| 45 | + |
| 46 | +```lua |
| 47 | +require('sqlformat').setup({ |
| 48 | + indent = 2, -- Number of spaces for indentation |
| 49 | + keyword_case = 'upper', -- 'upper' or 'lower' for SQL keywords |
| 50 | + line_width = 80, -- Maximum line width |
| 51 | + format_on_save = false, -- Enable/disable format on save |
| 52 | + custom_keymaps = { -- Custom keybindings |
| 53 | + format = '<leader>sf' |
| 54 | + } |
| 55 | +}) |
| 56 | +``` |
| 57 | + |
| 58 | +============================================================================== |
| 59 | +REQUIREMENTS *sqlformat-requirements* |
| 60 | + |
| 61 | +- Neovim with Python 3 support |
| 62 | +- sqlparse Python package |
| 63 | + |
| 64 | +Install sqlparse: |
| 65 | + pip install sqlparse |
| 66 | + |
| 67 | +============================================================================== |
| 68 | +TROUBLESHOOTING *sqlformat-troubleshooting* |
| 69 | + |
| 70 | +1. Plugin not working: |
| 71 | + - Ensure Neovim has Python 3 support |
| 72 | + - Check if sqlparse is installed |
| 73 | + - Verify Python path in Neovim |
| 74 | + |
| 75 | +2. Format on save not working: |
| 76 | + - Check if format_on_save is enabled |
| 77 | + - Ensure file has .sql extension |
| 78 | + |
| 79 | +============================================================================== |
| 80 | +LICENSE *sqlformat-license* |
| 81 | + |
| 82 | +This plugin is licensed under the MIT License. |
| 83 | + |
| 84 | +============================================================================== |
| 85 | +vim:tw=78:ts=8:ft=help:norl: |
0 commit comments