diff --git a/README.md b/README.md index 589b356..b1b2c15 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ WIP! - Route controller/form - Hook references - Permission references +- Plugin references ### Go to definition - Service references - Service class @@ -18,12 +19,23 @@ WIP! - Route controller/form - Hook references - Permission references +- Plugin references ### Completion - Services - Routes -- Hook snippets -- General snippets +- Snippets + - A few QoL improving snippets. + - Hooks + - form-[ELEMENT] + - render-[ELEMENT] - Permissions +- Plugin IDs (limited to:) + - EntityType + - QueueWorker + - FieldType + - DataType + - FormElement + - RenderElement ## Installation @@ -59,7 +71,6 @@ WIP! ## Roadmap ### Completion -- [ ] Autocomplete plugin IDs (eg. queue workers, blocks, fields, migrate source/process/destination). - [ ] Autocomplete #theme functions. ### Code actions diff --git a/src/main.rs b/src/main.rs index 28d8798..22ee9a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,7 +37,7 @@ async fn main() -> Result<()> { builder.init(); log::trace!("log options: {:?}", config); - match start_lsp().await { + match start_lsp(config).await { Ok(_) => (), Err(error) => log::error!("An unexpected error happened: {:?}", error), }; diff --git a/src/opts.rs b/src/opts.rs index bdc229f..7a62bd4 100644 --- a/src/opts.rs +++ b/src/opts.rs @@ -11,4 +11,22 @@ pub struct DrupalLspConfig { /// Valid values are: TRACE, DEBUG, INFO, WARN, ERROR #[clap(short, long, default_value = "INFO")] pub level: String, + + /// Uses stdio as the communication channel, will be as the default communication channel. + #[clap(short, long)] + pub stdio: bool, + + /// Use pipes (Windows) or socket files (Linux, Mac) as the communication channel. + /// The pipe / socket file name is passed as the next arg or with --pipe=. + /// Unsupported for now! + #[clap(short, long)] + pub pipe: Option, + + /// Uses a socket as the communication channel. The port is passed as next arg or with --port=. + #[clap(short, long)] + pub socket: Option, + + /// The port to use for the socket connection. + #[clap(short, long)] + pub port: Option, } diff --git a/src/server/mod.rs b/src/server/mod.rs index 4077bc9..b2a6bf2 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -2,6 +2,7 @@ mod handle_notification; mod handle_request; mod handlers; +use std::net::{Ipv4Addr, SocketAddrV4}; use std::vec; use anyhow::Result; @@ -12,6 +13,7 @@ use lsp_types::{ }; use crate::document_store::initialize_document_store; +use crate::opts::DrupalLspConfig; use crate::utils::uri_to_url; use self::handle_notification::handle_notification; @@ -32,13 +34,19 @@ async fn main_loop(connection: Connection) { } } -pub async fn start_lsp() -> Result<()> { +pub async fn start_lsp(config: DrupalLspConfig) -> Result<()> { // Note that we must have our logging only write out to stderr. log::info!("Starting Drupal Language server"); - // Create the transport. Includes the stdio (stdin and stdout) versions but this could - // also be implemented to use sockets or HTTP. - let (connection, io_threads) = Connection::stdio(); + let (connection, io_threads); + if let Some(socket_port) = config.socket.or(config.port) { + (connection, io_threads) = + Connection::connect(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), socket_port))?; + } else if config.pipe.is_some() { + panic!("Unsupported transport type 'pipe'."); + } else { + (connection, io_threads) = Connection::stdio(); + } // Run the server and wait for the two threads to end (typically by trigger LSP Exit event). let server_capabilities = serde_json::to_value(&ServerCapabilities {