Skip to content

Commit

Permalink
refactor: Replace .vim files with .lua
Browse files Browse the repository at this point in the history
Closes #525
  • Loading branch information
kristijanhusak committed Jan 16, 2024
1 parent be6811b commit 651078a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 50 deletions.
35 changes: 35 additions & 0 deletions ftplugin/org.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
if vim.b.did_ftplugin then
return
end
---@diagnostic disable-next-line: inject-field
vim.b.did_ftplugin = true

local config = require('orgmode.config')

config:setup_mappings('org')
config:setup_mappings('text_objects')
config:setup_foldlevel()

vim.bo.modeline = false
vim.opt_local.fillchars:append('fold: ')
vim.opt_local.foldmethod = 'expr'
vim.opt_local.foldexpr = 'nvim_treesitter#foldexpr()'
vim.opt_local.foldtext = 'v:lua.require("orgmode.org.indent").foldtext()'
vim.opt_local.formatexpr = 'v:lua.require("orgmode.org.format")()'
vim.opt_local.omnifunc = 'v:lua.orgmode.omnifunc'
vim.opt_local.commentstring = '# %s'

_G.orgmode.omnifunc = function(findstart, base)
return require('orgmode.org.autocompletion.omni').omnifunc(findstart, base)
end

local abbreviations = {
[':today:'] = "require('orgmode.objects.date').today():to_wrapped_string(true)",
[':now:'] = "require('orgmode.objects.date').now():to_wrapped_string(true)",
[':itoday:'] = "require('orgmode.objects.date').today():to_wrapped_string(false)",
[':inow:'] = "require('orgmode.objects.date').now():to_wrapped_string(false)",
}

for abbrev, cmd in pairs(abbreviations) do
vim.cmd.inoreabbrev(('<silent><buffer> %s <C-R>=luaeval("%s")<CR>'):format(abbrev, cmd))
end
37 changes: 0 additions & 37 deletions ftplugin/org.vim

This file was deleted.

10 changes: 10 additions & 0 deletions indent/org.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if vim.b.did_indent then
return
end
---@diagnostic disable-next-line: inject-field
vim.b.did_indent = true

vim.bo.indentexpr = 'v:lua.require("orgmode.org.indent").indentexpr()'
vim.bo.lisp = false
vim.bo.smartindent = false
vim.bo.autoindent = true
13 changes: 0 additions & 13 deletions indent/org.vim

This file was deleted.

0 comments on commit 651078a

Please sign in to comment.