2024-12-28

Sublime Text Config for Laravel

sublime text config for laravel

本文档介绍了笔者使用 Sublime Text 编辑器进行 Laravel 应用开发时的配置方案。

插件

以下插件显著提升了开发效率:

  • Git
  • Blame
  • GitGutter
  • AdvancedNewFile
  • SyncSideBar
  • LSP
  • LSP-intelephense
  • LSP-bash
  • LSP-dockerfile
  • LSP-eslint
  • LSP-json
  • Vue 语法高亮
  • LSP-slim
  • LSP-tailwindcss
  • Terminus
  • File Icons
  • Codeium
  • ShellExecute

插件安装方法:使用 cmd + shift + p / alt + shift + p 打开命令面板,选择“安装插件”进行安装。

LSP 配置

LSP 插件依赖 Node.js,请先安装 Node.js:

安装指南:https://www.php.cn/link/26dd3e3520fb7e479ba6e8f53f150d10
使用指南:https://www.php.cn/link/d999ac77ec9c98bd436d1016a6a8276a

Intelephense 配置

安装 Intelephense:

npm -g i intelephense
登录后复制

在 Sublime Text 中,打开 Preferences > Package Settings > LSP > Servers > lsp-intelephense,配置如下:

{
    "enabled": true,
    "command": [
        "intelephense",
        "--stdio",
    ],
    "scopes": ["source.php", "embedding.php"],
    "syntaxes": ["packages/php/php.sublime-syntax"],
    "languageid": "php",
    "initializationoptions": {
        "clearcache": false,
        "licencekey": "",
    },
}
登录后复制

启用 LSP:在命令面板中选择 LSP: Enable Language Server。

Sublime Text 设置

使用 cmd + , / alt + , 打开设置文件,添加以下配置:

{
    "ignored_packages": [
        "git",
        "git blame",
        "gitgutter",
        "vintage",
    ],
    "save_on_focus_lost": true,
    "shell_exec_executable": "/bin/zsh",
    "shell_exec_output": "panel",
    "shell_exec_output_word_wrap": false
}
登录后复制

按键绑定

添加以下按键绑定:

[
    {
        "command": "lsp_symbol_definition",
        "args": {
            "side_by_side": false
        },
        "keys": [
            "super+enter"
        ],
        "context": [
            {
                "key": "lsp.session_with_capability",
                "operator": "equal",
                "operand": "definitionprovider"
            },
            {
                "key": "auto_complete_visible",
                "operator": "equal",
                "operand": false
            }
        ]
    },
    // ...  (其余按键绑定保持不变)
]
登录后复制

鼠标绑定

添加以下鼠标绑定:

[
    {
        "button": "button1",
        "count": 1,
        "modifiers": ["super"],
        "press_command": "drag_select",
        "command": "lsp_symbol_definition"
    },
    {
        "button": "button1", "count": 1, "modifiers": ["ctrl"],
        "press_command": "drag_select",
        "press_args": {"additive": true}
    }
]
登录后复制

更多细节请访问我的博客原文。

以上就是Sublime Text Config for Laravel的详细内容,更多请关注php中文网其它相关文章!

https://www.php.cn/faq/1161459.html

发表回复

Your email address will not be published. Required fields are marked *