本文档介绍了笔者使用 Sublime Text 编辑器进行 Laravel 应用开发时的配置方案。
插件
以下插件显著提升了开发效率:
插件安装方法:使用 cmd + shift + p
/ alt + shift + p
打开命令面板,选择“安装插件”进行安装。
LSP 配置
LSP 插件依赖 Node.js,请先安装 Node.js:
安装指南:https://github.com/nvm-sh/nvm#installing-and-updating 使用指南:https://github.com/nvm-sh/nvm#usage
安装 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}
}
]
更多细节请访问我的博客原文。