【问题标题】:What file to modify atom's C++ grammar?什么文件可以修改 atom 的 C++ 语法?
【发布时间】:2018-10-15 10:25:58
【问题描述】:

我希望 atom 突出显示模板/类型,如 vector、map、vec2 等,所以基本上我想将它们作为标记添加到某处。

我可以添加自己的语法来替换默认语法吗?

我找到了这个https://flight-manual.atom.io/hacking-atom/sections/creating-a-grammar/,但它没有说明我应该修改什么文件。

【问题讨论】:

    标签: c++ editor syntax-highlighting atom-editor


    【解决方案1】:

    我对 C++ 了解不多,但如果这些类型是规范的一部分并且在 official package 中缺失,您是否考虑过提议添加它们?

    如果不能这样使用third-party packages,您可能希望扩展现有包。为此,您可以将捆绑的 C++ 包中的语法包含到您的自定义语法中,并添加(或覆盖)其模式。

    'scopeName': 'source.cpp.custom'
    'fileTypes': [
      'cc'
      'cpp'
      'cp'
      'cxx'
      'c++'
      'cu'
      'cuh'
      'h'
      'hh'
      'hpp'
      'hxx'
      'h++'
      'inl'
      'ino'
      'ipp'
      'tcc'
      'tpp'
    ]
    name: "My Custom CPP"
    patterns: [
      {
        # include all patterns from the bundled C++ grammar
        include: "source.cpp"
      }
      # add you custom patterns here to extend the bundled grammar
    ]
    

    如果您更喜欢扩展非捆绑的 C++ 包,请查看atom-package-deps,它允许您依赖第三方包。

    【讨论】:

      【解决方案2】:

      这个问题的答案并不简单。

      必须首先使用 apm 创建一个克隆包,对其进行修改,然后激活它或在开发模式下使用它。这些文件是 c++.cson 和 tree-sitter-cpp.cson。与 textmate 和 sublime text 相比,这些文件是相似的。

      我在他们的 slack 频道上问过,涉及几个步骤。我不认为这是一个应该计划做的事情,因为 atom 将这些包“预编译”到 v8 js 的大博客中,所以你不能直接修改默认文件,你必须告诉 atom 使用自定义包。问题是这个包在创建时有一个 node_modules 目录,里面有 400 多个文件。

      我设法做到了,但感觉很笨拙,所以我完全放弃了使用 atom,并继续使用 sublime 文本。

      【讨论】:

        猜你喜欢
        • 2021-09-05
        • 2011-12-21
        • 2016-06-24
        • 1970-01-01
        • 2012-09-03
        • 2022-12-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多