Nicolas Noben

Change LSP settings in BBEdit for Intelliphense

LSP, BBEdit, PHP, Intelliphense

2023-04-10

Introduction

Recently having moved to BBEdit, one thing that drove me crazy was the formatting using intelliphense (PHP) would automatically use PSR12 (default) where it puts the curly brace on a new line.

Say what you will about code style and all but I wanted K&R.

In VSCode this is trivial, edit the config, add a line and done. In BBEdit, not so quick!

The setup

Once you have intelliphense set up properly in BBEdit - see this page and search for "php": https://www.barebones.com/support/bbedit/lsp-notes.html

Got to ~/Library/Application Support/BBEdit/

You should see a folder Language Server, in there you'll find probably something for intelliphense such as storage.

See if there is a Configuration folder or create it. In there, create a php.json or whatever you'd like to call it, to hold your intelliphense config.

So the file is ~/Library/Application Support/BBEdit/Language Servers/Configuration/php.json

Here is my final json

{
	"initializationOptions":
	{
	},

	"workspaceConfigurations":
	{
		"*":
		{
			"intelephense":
			{
				"format": {"braces": "k&r"}
			}
		}
	}
}

Change the k&r to your preferred format. I've used this emacs reference to find the settings name: https://emacs-lsp.github.io/lsp-mode/page/lsp-intelephense/#lsp-intelephense-format-braces

Save it, restart BBEdit.

The usage

Screenshot 1 of BBEdit LSP settings Screenshot 2 of BBEdit LSP settings

Restart BBEdit and the next time you format code, your braces should be as you intended!

HTH.