diff --git a/docs/configuration.org b/docs/configuration.org index ac5f062b7..bbcf609cf 100644 --- a/docs/configuration.org +++ b/docs/configuration.org @@ -364,6 +364,16 @@ The indent value for content within =SRC= block types beyond the existing indent of the block itself. Only applied when exiting from an =org_edit_special= action on a =SRC= block. +*** org_edit_src_filetype_map +:PROPERTIES: +:CUSTOM_ID: org_edit_src_filetype_map +:END: +- Type: =table= +- Default: ={}= +This filetype map associates the language name from an Org source block +with the corresponding Vim filetype, which is then applied to the temporary +buffer. + *** org_custom_exports :PROPERTIES: :CUSTOM_ID: org_custom_exports diff --git a/lua/orgmode/config/defaults.lua b/lua/orgmode/config/defaults.lua index 7998b066b..300aaa5b9 100644 --- a/lua/orgmode/config/defaults.lua +++ b/lua/orgmode/config/defaults.lua @@ -61,6 +61,7 @@ local DefaultConfig = { }, org_src_window_setup = 'top 16new', org_edit_src_content_indentation = 0, + org_edit_src_filetype_map = {}, org_id_uuid_program = 'uuidgen', org_id_ts_format = '%Y%m%d%H%M%S', org_id_method = 'uuid', diff --git a/lua/orgmode/utils/init.lua b/lua/orgmode/utils/init.lua index 2e6c698c9..f1755d711 100644 --- a/lua/orgmode/utils/init.lua +++ b/lua/orgmode/utils/init.lua @@ -564,6 +564,7 @@ end ---@param skip_ftmatch? boolean ---@return string function utils.detect_filetype(name, skip_ftmatch) + local config = require('orgmode.config') local map = { ['emacs-lisp'] = 'lisp', elisp = 'lisp', @@ -586,6 +587,9 @@ function utils.detect_filetype(name, skip_ftmatch) if map[name] then return map[name] end + if config.org_edit_src_filetype_map[name] then + return config.org_edit_src_filetype_map[name] + end return name:lower() end