Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support TCP/Socket communication channel #11

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Consider adding this to your configuration.
(require 'eglot-ltex)
(eglot-ensure)))
:init
(setq eglot-ltex-server-path "path/to/ltex-ls-XX.X.X/"))
(setq eglot-ltex-server-path "path/to/ltex-ls-XX.X.X/"
eglot-ltex-communication-channel 'stdio)) ; 'stdio or 'tcp
```

## 🔧 Configuration
Expand Down Expand Up @@ -118,4 +119,4 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

See [`LICENSE`](./LICENSE.txt) for details.
See [`LICENSE`](./LICENSE) for details.
13 changes: 12 additions & 1 deletion eglot-ltex.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

;;; Code:

(require 'cl-lib)

(require 'eglot)
(require 'f)

Expand Down Expand Up @@ -68,6 +70,12 @@ https://github.com/valentjn/ltex-ls"
:type 'string
:group 'eglot-ltex)

(defcustom eglot-ltex-communication-channel 'stdio
"Type of the communication channel."
:type '(choice (const :tag "Standard IO" stdio)
(const :tag "TCP/socket" tcp))
:group 'eglot-ltex)

(defun eglot-ltex--server-entry ()
"Return the server entry file.

Expand All @@ -78,7 +86,10 @@ This file is use to activate the language server."

(defun eglot-ltex--server-command ()
"Generate startup command for LTEX language server."
(list (eglot-ltex--server-entry) "--server-type" "TcpSocket" "--port" :autoport))
(cl-case eglot-ltex-communication-channel
(`stdio `(,(eglot-ltex--server-entry)))
(`tcp `(,(eglot-ltex--server-entry) "--server-type" "TcpSocket" "--port" :autoport))
(t (user-error "Invalid communication channel type: %s" eglot-ltex-communication-channel))))

(add-to-list 'eglot-server-programs
`(,eglot-ltex-active-modes . ,(eglot-ltex--server-command)))
Expand Down
Loading