-- TIME_STAMP 2022-02-08 10:50:16 --[[ CompileNimByUserline.lua by BugFix Nim compiler user guide: https://nim-lang.org/docs/nimc.html Insert the compilation line into one of the first programme lines: # compile: nim command [options] [projectfile] [arguments] example compile: # compile: nim c --app:console Test.nim example compile & run: # compile: nim c -r --app:console Test.nim This line is used for compilation. The Lua script works in a different subsystem than Nim-Go. This means that an execution of the menu command IDM_GO from the Lua script is not successful. If no compilation line is included in the script, is used as default: nim c -r "$(FileNameExt)" Two steps for using required: 1. One Hotkey calls "CompileNimByUserline.lua" The compile line is extracted and saved as property "nim.compile.line" 2. Another Hotkey calls command "Go". The command "Go" executes the property "nim.compile.line". REQUIRED CHANGES IN "SciTEUser.properties": # ======================================================== N I M ==== # F5 #~ command.go.*.nim=nim c -r "$(FileNameExt)" command.go.*.nim=$(nim.compile.line) command.go.subsystem.*.nim=1 command.name.1.*.nim=Syntax Check command.1.*.nim=nim check "$(FilePath)" command.mode.1.*.nim=savebefore:yes command.shortcut.1.*.nim=Ctrl+F5 command.name.2.*.nim=Compile / Go by User Line command.2.*.nim=dofile $(Lua.User.Scripts.Path)/CompileNimByUserline.lua <<== Modify your path !! command.mode.2.*.nim=subsystem:lua,savebefore:yes command.shortcut.2.*.nim=Ctrl+1 # compile Ctrl+F7 command.compile.*.nim=nim c "$(FilePath)" # build F7 command.build.*.nim=nim --forcebuild "$(FilePath)" command.build.subsystem.*.nim=1 comment.block.nimrod=# # ======================================================= /N I M ==== --]] local function getCompileLine() local text = editor:GetText() local match, kind, go = nil, '> Compile & Go Nim by Default\n', '' for m in text:gmatch('#%scompile:%s+([^\r\n]+)') do match = m break end if match ~= nil then if match:find('%-r') then go = '& Go ' end kind = '> Compile '..go..'Nim by UserLine\n' props['nim.compile.line'] = match else props['nim.compile.line'] = 'nim c -r '..props['FileNameExt'] end return kind end if props['FileExt']:lower() == 'nim' then local kind = getCompileLine() output:ClearAll() output:AppendText(kind) -- scite.MenuCommand(IDM_GO) doesn't work, syntax error: too many chunks end