Customized fork of github.com/rxi/lite

Added `doc/usage.md`

Resolves #158
Resolves #103

rxi 2caa7f18 91c43dc0

Changed files
+147
doc
+1
README.md
··· 5 5 6 6 * **[Get lite](https://github.com/rxi/lite/releases/latest)** — Download 7 7 for Windows and Linux 8 + * **[Get started](doc/usage.md)** — A quick overview on how to get started 8 9 * **[Get plugins](https://github.com/rxi/lite-plugins)** — Add additional 9 10 functionality 10 11 * **[Get color themes](https://github.com/rxi/lite-colors)** — Add additional colors
+146
doc/usage.md
··· 1 + # lite 2 + 3 + ![screenshot](https://user-images.githubusercontent.com/3920290/81471642-6c165880-91ea-11ea-8cd1-fae7ae8f0bc4.png) 4 + 5 + ## Overview 6 + lite is a lightweight text editor written mostly in Lua — it aims to provide 7 + something practical, pretty, *small* and fast, implemented as simply as 8 + possible; easy to modify and extend, or to use without doing either. 9 + 10 + 11 + ## Getting Started 12 + When lite is started it's typically opened with a *project directory* — this 13 + is the directory where your project's code and other data resides. The project 14 + directory is set once when lite is started and, for the duration of the 15 + session, cannot be changed. 16 + 17 + To open lite with a specific project directory the directory name can be passed 18 + as a command-line argument *(`.` can be passed to use the current directory)* or 19 + the directory can be dragged onto either the lite executable or a running 20 + instance of lite. 21 + 22 + The main way of opening files in lite is through the `core:find-file` command 23 + — this provides a fuzzy finder over all of the project's files and can be 24 + opened using the **`ctrl+p`** shortcut by default. 25 + 26 + Commands can be run using keyboard shortcuts, or by using the `core:find-command` 27 + command bound to **`ctrl+shift+p`** by default. For example, pressing 28 + `ctrl+shift+p` and typing `newdoc` then pressing `return` would open a new 29 + document. The current keyboard shortcut for a command can be seen to the right 30 + of the command name on the command finder, thus to find the shortcut for a command 31 + `ctrl+shift+p` can be pressed and the command name typed. 32 + 33 + 34 + ## User Module 35 + lite can be configured through use of the user module. The user module can be 36 + used for changing options in the config module, adding additional key bindings, 37 + loading custom color themes, modifying the style or changing any other part of 38 + lite to your personal preference. 39 + 40 + The user module is loaded by lite when the application starts, after the plugins 41 + have been loaded. 42 + 43 + The user module can be modified by running the `core:open-user-module` command 44 + or otherwise directly opening the `data/user/init.lua` file. 45 + 46 + 47 + ## Project Module 48 + The project module is an optional module which is loaded from the current 49 + project's directory when lite is started. Project modules can be useful for 50 + things like adding custom commands for project-specific build systems, or 51 + loading project-specific plugins. 52 + 53 + The project module is loaded by lite when the application starts, after both the 54 + plugins and user module have been loaded. 55 + 56 + The project module can be edited by running the `core:open-project-module` 57 + command — if the module does not exist for the current project when the 58 + command is run it will be created. 59 + 60 + 61 + ## Commands 62 + Commands in lite are used both through the command finder (`ctrl+shift+p`) and 63 + by lite's keyboard shortcut system. Commands consist of 3 components: 64 + * **Name** — The command name in the form of `namespace:action-name`, for 65 + example: `doc:select-all` 66 + * **Predicate** — A function that returns true if the command can be ran, for 67 + example, for any document commands the predicate checks whether the active 68 + view is a document 69 + * **Function** — The function which performs the command itself 70 + 71 + Commands can be added using the `command.add` function provided by the 72 + `core.command` module: 73 + ```lua 74 + local core = require "core" 75 + local command = require "core.command" 76 + 77 + command.add("core.docview", { 78 + ["doc:save"] = function() 79 + core.active_view.doc:save() 80 + core.log("Saved '%s', core.active_view.doc.filename) 81 + end 82 + }) 83 + ``` 84 + 85 + Commands can be performed programatically (eg. from another command or by your 86 + user module) by calling the `command.perform` function after requiring the 87 + `command` module: 88 + ```lua 89 + local command = require "core.command" 90 + command.perform "core:quit" 91 + ``` 92 + 93 + 94 + ## Keymap 95 + All keyboard shortcuts in lite are handled by the `core.keymap` module. A key 96 + binding in lite maps a "stroke" (eg. `ctrl+q`) to one or more commands (eg. 97 + `core:quit`). When the shortcut is pressed lite will iterate each command 98 + assigned to that key and run the *predicate function* for that command — if the 99 + predicate passes it stops iterating and runs the command. 100 + 101 + An example of where this used is the default binding of the `tab` key: 102 + ``` lua 103 + ["tab"] = { "command:complete", "doc:indent" }, 104 + ``` 105 + When tab is pressed the `command:complete` command is attempted which will only 106 + succeed if the command-input at the bottom of the window is active. Otherwise 107 + the `doc:indent` command is attempted which will only succeed if we have a 108 + document as our active view. 109 + 110 + A new mapping can be added by your user module as follows: 111 + ```lua 112 + local keymap = require "core.keymap" 113 + keymap.add { ["ctrl+q"] = "core:quit" } 114 + ``` 115 + 116 + 117 + ## Plugins 118 + Plugins in lite are normal lua modules and are treated as such — no 119 + complicated plugin manager is provided, and, once a plugin is loaded, it is never 120 + expected be to have to unload itself. 121 + 122 + To install a plugin simply drop it in the `data/plugins` directory — installed 123 + plugins will be automatically loaded when lite starts. To uninstall a plugin the 124 + plugin file can be deleted — any plugin (including those included with lite's 125 + default installation) can be deleted to remove its functionality. 126 + 127 + If you want to load a plugin only under a certain circumstance (for example, 128 + only on a given project) the plugin can be placed somewhere other than the 129 + `data/plugins` directory so that it is not automatically loaded. The plugin can 130 + then be loaded manually as needed by using the `require` function. 131 + 132 + Plugins can be downloaded from the [plugins repository](https://github.com/rxi/lite-plugins). 133 + 134 + 135 + ## Color Themes 136 + Colors themes in lite are lua modules which overwrite the color fields of lite's 137 + `core.style` module. Color themes should be placed in the `data/user/colors` 138 + directory. 139 + 140 + A color theme can be set by requiring it in your user module: 141 + ```lua 142 + require "user.colors.winter" 143 + ``` 144 + 145 + Color themes can be downloaded from the [color themes repository](https://github.com/rxi/lite-colors). 146 +