Skip to content

Commit

Permalink
? is a valid identifier character in Lean.
Browse files Browse the repository at this point in the history
In particular, this fixes Try This message swapping from the exact?
and apply? tactics, as well as the behavior of `daw` etc.
  • Loading branch information
Julian committed Jul 19, 2023
1 parent 891294b commit bb2ac98
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ftplugin/lean/lean.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ vim.b.did_ftplugin = 1

vim.opt.wildignore:append[[*.olean]]

vim.opt_local.iskeyword = [[a-z,A-Z,_,48-57,192-255,!,']]
vim.opt_local.iskeyword = [[a-z,A-Z,_,48-57,192-255,!,',?]]
vim.opt_local.comments = [[s0:/-,mb:\ ,ex:-/,:--]]
vim.opt_local.commentstring=[[/- %s -/]]

Expand Down
15 changes: 14 additions & 1 deletion lua/tests/trythis_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@ local helpers = require('tests.helpers')
require('lean').setup {}

describe('trythis', function()
it('replaces a single try this', helpers.clean_buffer('lean3', [[
it('replaces a single try this', helpers.clean_buffer('lean', [[
macro "whatshouldIdo?" : tactic => `(tactic| trace "Try this: rfl")
example : 2 = 2 := by whatshouldIdo?]], function()
vim.api.nvim_command('normal G$')
helpers.wait_for_line_diagnostics()

require('lean.trythis').swap()
assert.is.same(
'example : 2 = 2 := by rfl',
vim.api.nvim_get_current_line()
)
end))

it('replaces a single try this in lean3', helpers.clean_buffer('lean3', [[
meta def whatshouldIdo := (do tactic.trace "Try this: existsi 2; refl\n")
example : ∃ n, n = 2 := by whatshouldIdo]], function()
vim.api.nvim_command('normal G$')
Expand Down
2 changes: 1 addition & 1 deletion syntax/lean.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
syn case match

" Valid identifiers (an incomplete list...)
syn iskeyword a-z,A-Z,_,48-57,192-255,!,.,'
syn iskeyword a-z,A-Z,_,48-57,192-255,!,.,',?

" keywords

Expand Down

0 comments on commit bb2ac98

Please sign in to comment.