Skip to content

Commit 2303489

Browse files
committed
feat(edit_src): Add org_edit_src_filetype_map for custom src block filetypes.
1 parent b6d14eb commit 2303489

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-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: 2 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',
@@ -576,6 +577,7 @@ function utils.detect_filetype(name, skip_ftmatch)
576577
shell = 'bash',
577578
uxn = 'uxntal',
578579
}
580+
map = vim.tbl_deep_extend('force', map, config.org_edit_src_filetype_map)
579581
if not skip_ftmatch then
580582
local filename = '__org__detect_filetype__.' .. (map[name] or name)
581583
local ft = vim.filetype.match({ filename = filename })

0 commit comments

Comments
 (0)