diff --git a/changelog.d/20241024_205738_github-actions[bot]_remove-old-workarounds.rst b/changelog.d/20241024_205738_github-actions[bot]_remove-old-workarounds.rst new file mode 100644 index 000000000..29150aee8 --- /dev/null +++ b/changelog.d/20241024_205738_github-actions[bot]_remove-old-workarounds.rst @@ -0,0 +1,7 @@ +.. _#2196: https://github.com/fox0430/moe/pull/2196 + +Changed +....... + +- `#2196`_ Remove old workarounds + diff --git a/src/moepkg/exmodeutils.nim b/src/moepkg/exmodeutils.nim index 81043d13b..b00982d98 100644 --- a/src/moepkg/exmodeutils.nim +++ b/src/moepkg/exmodeutils.nim @@ -321,68 +321,35 @@ const argsType: ArgsType.none) ] -when (NimMajor, NimMinor) >= (1, 9): - # These codes can't compile in Nim 1.6. Maybe compiler bug. - - proc noArgsCommandList*(): seq[Runes] {.compileTime.} = - ExCommandInfoList - .filterIt(it.argsType == ArgsType.none) - .mapIt(it.command.toRunes) - - proc toggleArgsCommandList*(): seq[Runes] {.compileTime.} = - ExCommandInfoList - .filterIt(it.argsType == ArgsType.toggle) - .mapIt(it.command.toRunes) - - proc numberArgsCommandList*(): seq[Runes] {.compileTime.} = - ExCommandInfoList - .filterIt(it.argsType == ArgsType.number) - .mapIt(it.command.toRunes) - - proc textArgsCommandList*(): seq[Runes] {.compileTime.} = - ExCommandInfoList - .filterIt(it.argsType == ArgsType.text) - .mapIt(it.command.toRunes) - - proc pathArgsCommandList*(): seq[Runes] {.compileTime.} = - ExCommandInfoList - .filterIt(it.argsType == ArgsType.path) - .mapIt(it.command.toRunes) - - proc themeArgsCommandList*(): seq[Runes] {.compileTime.} = - ExCommandInfoList - .filterIt(it.argsType == ArgsType.theme) - .mapIt(it.command.toRunes) -else: - proc noArgsCommandList*(): seq[Runes] = - ExCommandInfoList - .filterIt(it.argsType == ArgsType.none) - .mapIt(it.command.toRunes) - - proc toggleArgsCommandList*(): seq[Runes] = - ExCommandInfoList - .filterIt(it.argsType == ArgsType.toggle) - .mapIt(it.command.toRunes) - - proc numberArgsCommandList*(): seq[Runes] = - ExCommandInfoList - .filterIt(it.argsType == ArgsType.number) - .mapIt(it.command.toRunes) - - proc textArgsCommandList*(): seq[Runes] = - ExCommandInfoList - .filterIt(it.argsType == ArgsType.text) - .mapIt(it.command.toRunes) - - proc pathArgsCommandList*(): seq[Runes] = - ExCommandInfoList - .filterIt(it.argsType == ArgsType.path) - .mapIt(it.command.toRunes) - - proc themeArgsCommandList*(): seq[Runes] = - ExCommandInfoList - .filterIt(it.argsType == ArgsType.theme) - .mapIt(it.command.toRunes) +proc noArgsCommandList*(): seq[Runes] {.compileTime.} = + ExCommandInfoList + .filterIt(it.argsType == ArgsType.none) + .mapIt(it.command.toRunes) + +proc toggleArgsCommandList*(): seq[Runes] {.compileTime.} = + ExCommandInfoList + .filterIt(it.argsType == ArgsType.toggle) + .mapIt(it.command.toRunes) + +proc numberArgsCommandList*(): seq[Runes] {.compileTime.} = + ExCommandInfoList + .filterIt(it.argsType == ArgsType.number) + .mapIt(it.command.toRunes) + +proc textArgsCommandList*(): seq[Runes] {.compileTime.} = + ExCommandInfoList + .filterIt(it.argsType == ArgsType.text) + .mapIt(it.command.toRunes) + +proc pathArgsCommandList*(): seq[Runes] {.compileTime.} = + ExCommandInfoList + .filterIt(it.argsType == ArgsType.path) + .mapIt(it.command.toRunes) + +proc themeArgsCommandList*(): seq[Runes] {.compileTime.} = + ExCommandInfoList + .filterIt(it.argsType == ArgsType.theme) + .mapIt(it.command.toRunes) proc exCommandList*(): array[ExCommandInfoList.len, Runes] {.compileTime.} = for i, info in ExCommandInfoList: result[i] = info.command.toRunes diff --git a/src/moepkg/insertmode.nim b/src/moepkg/insertmode.nim index 88c0cae64..17457d241 100644 --- a/src/moepkg/insertmode.nim +++ b/src/moepkg/insertmode.nim @@ -21,13 +21,9 @@ import std/[options, json, logging, tables] import pkg/results -import lsp/client - -# Workaround for Nim 1.6.2 +import lsp/[client, signaturehelp] import lsp/completion as lspcompletion -import lsp/signaturehelp - import ui, editorstatus, windownode, movement, editor, bufferstatus, settings, unicodeext, independentutils, gapbuffer, completion, messages diff --git a/src/moepkg/lsp/handler.nim b/src/moepkg/lsp/handler.nim index fff135241..0162ede11 100644 --- a/src/moepkg/lsp/handler.nim +++ b/src/moepkg/lsp/handler.nim @@ -43,15 +43,14 @@ import ../statusline, ../visualmode +import completion as lspcompletion + import client, utils, hover, message, diagnostics, semantictoken, progress, inlayhint, definition, typedefinition, references, rename, declaration, implementation, callhierarchy, documenthighlight, documentlink, codelens, executecommand, foldingrange, selectionrange, documentsymbol, inlinevalue, signaturehelp, formatting -# Workaround for Nim 1.6.2 -import completion as lspcompletion - proc applyTextEdit(b: var BufferStatus, edit: TextEdit): Result[(), string] = let startLine = edit.range.start.line diff --git a/src/moepkg/normalmode.nim b/src/moepkg/normalmode.nim index 63fb84055..86e78a71d 100644 --- a/src/moepkg/normalmode.nim +++ b/src/moepkg/normalmode.nim @@ -38,15 +38,16 @@ template removeAllFoldingRange(status: var EditorStatus, first, last: int) = proc changeModeToInsertMode( status: var EditorStatus, removeFoldingRange: bool = true) {.inline.} = - if currentBufStatus.isReadonly: - status.commandLine.writeReadonlyModeWarning - return - if removeFoldingRange: - status.removeAllFoldingRange + if currentBufStatus.isReadonly: + status.commandLine.writeReadonlyModeWarning + return + + if removeFoldingRange: + status.removeAllFoldingRange - changeCursorType(status.settings.standard.insertModeCursor) - status.changeMode(Mode.insert) + changeCursorType(status.settings.standard.insertModeCursor) + status.changeMode(Mode.insert) proc changeModeToReplaceMode(status: var EditorStatus) {.inline.} = if currentBufStatus.isReadonly: @@ -57,30 +58,30 @@ proc changeModeToReplaceMode(status: var EditorStatus) {.inline.} = status.changeMode(Mode.replace) -proc changeModeToVisualMode(status: var EditorStatus) {.inline.} = +template changeModeToVisualMode(status: var EditorStatus) = status.changeMode(Mode.visual) currentBufStatus.selectedArea = initSelectedArea( currentMainWindowNode.currentLine, currentMainWindowNode.currentColumn) .some -proc changeModeToVisualBlockMode(status: var EditorStatus) {.inline.} = +template changeModeToVisualBlockMode(status: var EditorStatus) = status.changeMode(Mode.visualBlock) currentBufStatus.selectedArea = initSelectedArea( currentMainWindowNode.currentLine, currentMainWindowNode.currentColumn) .some -proc changeModeToVisualLineMode(status: var EditorStatus) {.inline.} = +template changeModeToVisualLineMode(status: var EditorStatus) = status.changeMode(Mode.visualLine) currentBufStatus.selectedArea = initSelectedArea( currentMainWindowNode.currentLine, currentMainWindowNode.currentColumn) .some -proc changeModeToExMode*( +template changeModeToExMode*( bufStatus: var BufferStatus, - commandLine: var CommandLine) {.inline.} = + commandLine: var CommandLine) = bufStatus.changeMode(Mode.ex) commandLine.clear @@ -90,21 +91,15 @@ template moveCursorLeft(status: var EditorStatus) = for i in 0 ..< currentBufStatus.cmdLoop: currentMainWindowNode.keyLeft -proc moveCursorRight(status: var EditorStatus) {.inline.} = - ## Use proc not template for a workaround for Nim 1.6.2. - +template moveCursorRight(status: var EditorStatus) = for i in 0 ..< currentBufStatus.cmdLoop: currentBufStatus.keyRight(currentMainWindowNode) -proc moveCursorUp(status: var EditorStatus) {.inline.} = - ## Use proc not template for a workaround for Nim 1.6.2. - +template moveCursorUp(status: var EditorStatus) = for i in 0 ..< currentBufStatus.cmdLoop: currentBufStatus.keyUp(currentMainWindowNode) -proc moveCursorDwon(status: var EditorStatus) {.inline.} = - ## Use proc not template for a workaround for Nim 1.6.2. - +template moveCursorDwon(status: var EditorStatus) = for i in 0 ..< currentBufStatus.cmdLoop: currentBufStatus.keyDown(currentMainWindowNode) @@ -327,34 +322,24 @@ proc moveToFirstLine(status: var EditorStatus) = let dest = currentBufStatus.cmdLoop - 1 currentBufStatus.jumpLine(currentMainWindowNode, dest) -proc moveToForwardWord(status: var EditorStatus) {.inline.} = - ## Use proc for workaround for Nim 1.6.2. - +template moveToForwardWord(status: var EditorStatus) = for i in 0 ..< currentBufStatus.cmdLoop: currentBufStatus.moveToForwardWord(currentMainWindowNode) -proc moveToBackwardWord(status: var EditorStatus) {.inline.} = - ## Use proc for workaround for Nim 1.6.2. - +template moveToBackwardWord(status: var EditorStatus) = for i in 0 ..< currentBufStatus.cmdLoop: currentBufStatus.moveToBackwardWord(currentMainWindowNode) -proc moveToForwardEndOfWord(status: var EditorStatus) {.inline.} = - ## Use proc for workaround for Nim 1.6.2. - +template moveToForwardEndOfWord(status: var EditorStatus) = for i in 0 ..< currentBufStatus.cmdLoop: currentBufStatus.moveToForwardEndOfWord(currentMainWindowNode) -proc incNumberTextUnderCurosr(status: var EditorStatus) {.inline.} = - ## Use proc for workaround for Nim 1.6.2. - +template incNumberTextUnderCurosr(status: var EditorStatus) = currentBufStatus.modifyNumberTextUnderCurosr( currentMainWindowNode, currentBufStatus.cmdLoop) -proc decNumberTextUnderCurosr(status: var EditorStatus) {.inline.} = - ## Use proc for workaround for Nim 1.6.2. - +template decNumberTextUnderCurosr(status: var EditorStatus) = currentBufStatus.modifyNumberTextUnderCurosr( currentMainWindowNode, -currentBufStatus.cmdLoop)