Skip to content

Commit cb59abb

Browse files
committed
Markdown improvements with autolist indentation
The autolist plugin makes it really easy to edit markdown files, automatically inserting the - or 1 at the beginning of a new unordered or ordered list, respectively. To test it out, I updated the local TODO.md file with it, and it works great! Just have to remember to make autolist depend on autopairs, because autopairs clobbers some of the config. Also, treesitter's default indentation for markdown files is really bad, so we have to turn it off to get the proper indentation (where the first character of the second line of an unordered list item is directly underneath the first character of the first line).
1 parent 5f6ee7e commit cb59abb

4 files changed

Lines changed: 59 additions & 22 deletions

File tree

.markdownlint.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"MD013": false
3+
}

TODO.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@
99
## Macros
1010

1111
1. `q` to record
12-
1. Press the key to symbolize the register you want to store the macro in, e.g.
13-
'r' or '4'
14-
1. Do your thing
15-
1. Return to normal mode, press `q` to end the recording
16-
1. Play the macro with `@<register>`, or `@@` to re-run the last macro you ran
17-
1. You can also end your macro by typing `@<register>`, to recursively call
18-
your macro for the whole file
12+
2. Press the key to symbolize the register you want to store the macro in, e.g. 'r' or '4'
13+
3. Do your thing
14+
4. Return to normal mode, press `q` to end the recording
15+
5. Play the macro with `@<register>`, or `@@` to re-run the last macro you ran
16+
6. NOTE: You can also end your macro by typing `@<register>`, to recursively call your macro for the whole file
17+
7. View all macros by entering command mode + "registers" or "reg" for short.
1918

2019
## Tests
2120

@@ -24,8 +23,7 @@
2423

2524
## Git navigation
2625

27-
- TODO: See the commit for a particular line in Git blame, either on GitHub or
28-
in a preview window
26+
- TODO: See the commit for a particular line in Git blame, either on GitHub or in a preview window
2927
- TODO: Show git history of current file in descending chronological order
3028

3129
## Searching text
@@ -35,8 +33,7 @@ in a preview window
3533

3634
## Formatting
3735

38-
- `<leader>f` is where the `conform` plugin maps the formatting keyboard
39-
shortcut
36+
- `<leader>f` is where the `conform` plugin maps the formatting keyboard shortcut
4037
- TODO: Saving a markdown file should trim trailing whitespace
4138

4239
## Syntax highlighting
@@ -50,19 +47,14 @@ shortcut
5047

5148
## LSP (Language Server Protocol) lessons
5249

53-
- Mason is the plugin you use for installing LSPs, and you can debug why it's
54-
not installing a particular plugin with `:checkhealth mason`
55-
- (This is how you figured out why the TypeScript LSP wasn't installing --
56-
the health check showed that node wasn't installed.)
57-
- TODO: Figure out how to stop Lsp to see if it speeds up Rails development in
58-
screenings_app
59-
- TODO: Figure out how to get LSP working in the property_app (not in
60-
apm_bundle)
50+
- Mason is the plugin you use for installing LSPs, and you can debug why it's not installing a particular plugin with `:checkhealth mason`
51+
- (This is how you figured out why the TypeScript LSP wasn't installing -- the health check showed that node wasn't installed.)
52+
- TODO: Figure out how to stop Lsp to see if it speeds up Rails development in screenings_app
53+
- TODO: Figure out how to get LSP working in the property_app (not in apm_bundle)
6154

6255
## General wishlist
6356

64-
- TODO: Figure out how to yank the relative path of the current file in the
65-
buffer, so that you can paste file names more easily with your coworkers.
57+
- TODO: Figure out how to yank the relative path of the current file in the buffer, so that you can paste file names more easily with your coworkers.
6658
- TODO: Figure out how to install Copilot and use it occasionally
6759
- TODO: Figure out triple backticks syntax, useful for commit messages
6860

lua/plugins/indentation.lua

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,46 @@ return {
1212
require('guess-indent').setup {}
1313
end,
1414
},
15+
-- Automatically indent ordered and unordered lists in `ft` file types
16+
{
17+
'gaoDean/autolist.nvim',
18+
ft = {
19+
'markdown',
20+
'text',
21+
'tex',
22+
},
23+
dependencies = {
24+
{
25+
'windwp/nvim-autopairs',
26+
config = true,
27+
event = 'VeryLazy',
28+
},
29+
},
30+
config = function()
31+
require('autolist').setup()
32+
33+
vim.keymap.set('i', '<tab>', '<cmd>AutolistTab<cr>')
34+
vim.keymap.set('i', '<s-tab>', '<cmd>AutolistShiftTab<cr>')
35+
-- vim.keymap.set("i", "<c-t>", "<c-t><cmd>AutolistRecalculate<cr>") -- an example of using <c-t> to indent
36+
vim.keymap.set('i', '<CR>', '<CR><cmd>AutolistNewBullet<cr>')
37+
vim.keymap.set('n', 'o', 'o<cmd>AutolistNewBullet<cr>')
38+
vim.keymap.set('n', 'O', 'O<cmd>AutolistNewBulletBefore<cr>')
39+
vim.keymap.set('n', '<CR>', '<cmd>AutolistToggleCheckbox<cr><CR>')
40+
vim.keymap.set('n', '<C-r>', '<cmd>AutolistRecalculate<cr>')
41+
42+
-- cycle list types with dot-repeat
43+
vim.keymap.set('n', '<leader>cn', require('autolist').cycle_next_dr, { expr = true })
44+
vim.keymap.set('n', '<leader>cp', require('autolist').cycle_prev_dr, { expr = true })
45+
46+
-- if you don't want dot-repeat
47+
-- vim.keymap.set("n", "<leader>cn", "<cmd>AutolistCycleNext<cr>")
48+
-- vim.keymap.set("n", "<leader>cp", "<cmd>AutolistCycleNext<cr>")
49+
50+
-- functions to recalculate list on edit
51+
vim.keymap.set('n', '>>', '>><cmd>AutolistRecalculate<cr>')
52+
vim.keymap.set('n', '<<', '<<<cmd>AutolistRecalculate<cr>')
53+
vim.keymap.set('n', 'dd', 'dd<cmd>AutolistRecalculate<cr>')
54+
vim.keymap.set('v', 'd', 'd<cmd>AutolistRecalculate<cr>')
55+
end,
56+
},
1557
}

lua/plugins/treesitter.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ return { -- Highlight, edit, and navigate code
1414
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
1515
additional_vim_regex_highlighting = { 'ruby' },
1616
},
17-
indent = { enable = true, disable = { 'ruby' } },
17+
indent = { enable = true, disable = { 'markdown', 'ruby' } },
1818
fold = { enable = true },
1919
},
2020
-- There are additional nvim-treesitter modules that you can use to interact

0 commit comments

Comments
 (0)