Skip to content

Commit 7ffb34c

Browse files
authored
feat(edit_src): Add org_edit_src_filetype_map for custom src block filetypes. (#1002)
1 parent f88734b commit 7ffb34c

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

docs/configuration.org

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,16 @@ The indent value for content within =SRC= block types beyond the
364364
existing indent of the block itself. Only applied when exiting from an
365365
=org_edit_special= action on a =SRC= block.
366366

367+
*** org_edit_src_filetype_map
368+
:PROPERTIES:
369+
:CUSTOM_ID: org_edit_src_filetype_map
370+
:END:
371+
- Type: =table<string, string>=
372+
- Default: ={}=
373+
This filetype map associates the language name from an Org source block
374+
with the corresponding Vim filetype, which is then applied to the temporary
375+
buffer.
376+
367377
*** org_custom_exports
368378
:PROPERTIES:
369379
:CUSTOM_ID: org_custom_exports

lua/orgmode/config/defaults.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ local DefaultConfig = {
6161
},
6262
org_src_window_setup = 'top 16new',
6363
org_edit_src_content_indentation = 0,
64+
org_edit_src_filetype_map = {},
6465
org_id_uuid_program = 'uuidgen',
6566
org_id_ts_format = '%Y%m%d%H%M%S',
6667
org_id_method = 'uuid',

lua/orgmode/utils/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ end
564564
---@param skip_ftmatch? boolean
565565
---@return string
566566
function utils.detect_filetype(name, skip_ftmatch)
567+
local config = require('orgmode.config')
567568
local map = {
568569
['emacs-lisp'] = 'lisp',
569570
elisp = 'lisp',
@@ -586,6 +587,9 @@ function utils.detect_filetype(name, skip_ftmatch)
586587
if map[name] then
587588
return map[name]
588589
end
590+
if config.org_edit_src_filetype_map[name] then
591+
return config.org_edit_src_filetype_map[name]
592+
end
589593
return name:lower()
590594
end
591595

0 commit comments

Comments
 (0)