folds + very basic indentation
This commit is contained in:
parent
74f857ee4f
commit
a532a2e1dd
3 changed files with 38 additions and 1 deletions
|
|
@ -1,11 +1,38 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
local function get_indent(lnum)
|
||||||
|
local prev_line = vim.fn.getline(lnum - 1)
|
||||||
|
local curr_line = vim.fn.getline(lnum)
|
||||||
|
|
||||||
|
local prev_indent = vim.fn.indent(lnum - 1)
|
||||||
|
local shiftwidth = vim.bo.shiftwidth
|
||||||
|
|
||||||
|
if prev_line:match(';') then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
if prev_line:match(':=') then
|
||||||
|
return prev_indent + shiftwidth
|
||||||
|
end
|
||||||
|
|
||||||
|
return prev_indent
|
||||||
|
end
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
vim.filetype.add({
|
vim.filetype.add({
|
||||||
extension = { pg = 'perga' }
|
extension = { pg = 'perga' }
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.opt.commentstring = '-- %s'
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = "perga",
|
||||||
|
callback = function()
|
||||||
|
_G.get_perga_indent = get_indent
|
||||||
|
|
||||||
|
vim.bo.indentexpr = 'v:lua.get_perga_indent(v:lnum)'
|
||||||
|
vim.bo.indentkeys = '0{,0},0),0],!^F,o,O,e,:,='
|
||||||
|
vim.opt_local.commentstring = '-- %s'
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
local parser_config = require 'nvim-treesitter.parsers'.get_parser_configs()
|
local parser_config = require 'nvim-treesitter.parsers'.get_parser_configs()
|
||||||
parser_config.perga = {
|
parser_config.perga = {
|
||||||
|
|
|
||||||
6
queries/perga/folds.scm
Normal file
6
queries/perga/folds.scm
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
[
|
||||||
|
(definition)
|
||||||
|
(block_comment)
|
||||||
|
(labs)
|
||||||
|
(pabs)
|
||||||
|
] @fold
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
[(star) (square)] @constant.builtin
|
[(star) (square)] @constant.builtin
|
||||||
|
|
||||||
(comment) @comment
|
(comment) @comment
|
||||||
|
(block_comment) @comment
|
||||||
|
|
||||||
[ "(" ")" ] @punctuation.bracket
|
[ "(" ")" ] @punctuation.bracket
|
||||||
|
|
||||||
|
|
@ -17,3 +18,6 @@
|
||||||
|
|
||||||
(param_block
|
(param_block
|
||||||
type: (expr) @type)
|
type: (expr) @type)
|
||||||
|
|
||||||
|
(ascription
|
||||||
|
type: (expr) @type)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue