Skip to content

Commit 8d1ab9e

Browse files
committed
refact: minor refactor + updated docs
1 parent 022d0b8 commit 8d1ab9e

4 files changed

Lines changed: 28 additions & 13 deletions

File tree

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@ After installing Neovim, it took me some time to configure it, learn its setting
1414
I got fed up of constantly hitting `:`, typing `lua= command`, then typing `:messages` to see the output, only to find out that a made a typo or a
1515
syntax error and retyping the whole thing again, copying the paths from error stacktraces and so on. I needed something better, so there it is.
1616

17+
<br>
18+
1719
## ✨ Features
1820

1921
- Evaluate single line expressions and statements, visually selected lines of code or the whole buffer
20-
- Pretty print Lua objects, including function details and their source paths
21-
- Show normal and error output in the console/buffer, including output of `print()`, errors and stacktraces.
22+
- Pretty print Lua objects, including results of assignments, function details and their source paths
23+
- Show normal and error output inline in the console/buffer, including output of `print()`, errors and stacktraces.
2224
- Syntax highlighting and autocompletion
23-
- Load Neovim’s messages into console for inspection and copy/paste
25+
- Load Neovim’s messages and output of ex commands into console for inspection and copy/paste
2426
- Open links from stacktraces and function sources
2527
- Save / Load / Autosave console session
2628
- Use as a scratch pad for code gists
2729
- Attach code evaluators to any buffer
2830

31+
<br>
2932

3033
## 📦 Installation
3134

@@ -34,12 +37,18 @@ With [lazy.nvim](https://github.com/folke/lazy.nvim):
3437
```lua
3538
return {
3639
"yarospace/lua-console.nvim",
37-
lazy = true, keys = "`", opts = {},
40+
lazy = true,
41+
keys = {'`', '<Leader>`'},
42+
opts = {},
3843
}
3944
```
40-
otherwise, install with your favorite package manager and add
41-
`require('lua-console').setup { custom_options }` somewhere in your config.
45+
otherwise, install with your favorite package manager and add somewhere in your config:
46+
47+
```lua
48+
require('lua-console').setup { your_custom_options }
49+
```
4250

51+
<br>
4352

4453
## ⚙️ Configuration
4554

@@ -87,6 +96,7 @@ opts = {
8796

8897
</details>
8998

99+
<br>
90100

91101
## 🚀 Basic usage (with default mappings)
92102

@@ -110,6 +120,7 @@ opts = {
110120
saved whenever it is toggled or closed.
111121
- You can resize the console with `<C-Up>` and `<C-Down>`.
112122

123+
<br>
113124

114125
## 📓 Notes on globals, locals and preserving execution context
115126

@@ -129,6 +140,7 @@ There are two functions available within the console:
129140
- `_ctx()` - will print the contents of the context
130141
- `_ctx_clear()` - clears the context
131142

143+
<br>
132144

133145
## ⭐ Extra features
134146

@@ -257,6 +269,8 @@ There are two functions available within the console:
257269
]]
258270
```
259271

272+
<br>
273+
260274
## Alternatives and comparison
261275

262276
There are a number of alternatives available, notably:
@@ -268,5 +282,6 @@ There are a number of alternatives available, notably:
268282
Initially, when starting with Lua and Neovim, I tried all the REPLs/code runners I could find. However, I was not satisfied with all of them in one way or another.
269283
Lua-console is an attempt to combine the best features of all of them, like REPL / scratch pad / code runner / debug console, while leaving the UX and config simple.
270284

285+
<br>
271286

272287
## 🔥 All feedback and feature requests are very welcome! Enjoy!

lua/lazy.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
return {
22
'yarospace/lua-console.nvim',
33
lazy = true,
4-
keys = '`',
4+
keys = {'`', '<Leader>`'},
55
opts = {},
66
}

lua/lua-console.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
local config, mappings, utils, injections
1+
local config = require('lua-console.config')
2+
local mappings = require('lua-console.mappings')
3+
local utils = require('lua-console.utils')
4+
local injections = require('lua-console.injections')
25

36
local get_or_create_buffer = function()
47
--- @type number
@@ -77,10 +80,7 @@ end
7780
local setup = function(opts)
7881
_G.Lua_console = { buf = false, win = false, height = 0, ctx = {} }
7982

80-
config = require('lua-console.config').setup(opts)
81-
mappings = require('lua-console.mappings')
82-
utils = require('lua-console.utils')
83-
injections = require('lua-console.injections')
83+
config.setup(opts)
8484

8585
mappings.set_global_mappings()
8686
mappings.set_console_commands()

lua/lua-console/mappings.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
local M = {}
22

3-
local console = require('lua-console')
43
local config = require('lua-console.config')
54
local utils = require('lua-console.utils')
65

@@ -13,6 +12,7 @@ local function set_map(buf, map, opts, mode)
1312
end
1413

1514
M.set_global_mappings = function()
15+
local console = require('lua-console')
1616
local m = config.mappings
1717

1818
set_map(nil, m.toggle, {

0 commit comments

Comments
 (0)