html_languageservice/html_language_types.rs
1use lsp_types::ClientCapabilities;
2
3#[derive(Default)]
4pub struct HTMLLanguageServiceOptions {
5 /**
6 * Unless set to false, the default HTML data provider will be used
7 * along with the providers from customDataProviders.
8 * Defaults to true.
9 */
10 pub use_default_data_provider: Option<bool>,
11
12 /**
13 * Provide data that could enhance the service's understanding of
14 * HTML tag / attribute / attribute-value
15 */
16 // pub custom_data_providers: Option<Vec<Box<dyn IHTMLDataProvider>>>,
17
18 /**
19 * Abstract file system access away from the service.
20 * Used for path completion, etc.
21 */
22 pub file_system_provider: Option<Box<dyn FileSystemProvider>>,
23
24 /**
25 * Describes the LSP capabilities the client supports.
26 */
27 pub client_capabilities: Option<ClientCapabilities>,
28}
29
30pub trait FileSystemProvider: Send + Sync {
31 fn stat(&self, uri: DocumentUri) -> FileStat;
32
33 fn read_directory(&self, uri: DocumentUri) -> (String, FileType);
34}
35
36pub type DocumentUri = String;
37
38pub struct FileStat {
39 /// The type of the file, e.g. is a regular file, a directory, or symbolic link
40 /// to a file.
41 pub file_type: FileType,
42 /// The creation timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
43 pub ctime: i128,
44 /// The modification timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
45 pub mtime: i128,
46 /// The size in bytes.
47 pub size: usize,
48}
49
50pub enum FileType {
51 /// The file type is unknown.
52 Unknown = 0,
53 /// A regular file.
54 File = 1,
55 /// A directory.
56 Directory = 2,
57 /// A symbolic link to a file.
58 SymbolicLink = 64,
59}
60
61pub trait DocumentContext {
62 fn resolve_reference(&self, reference: &str, base: &str) -> Option<String>;
63}
64
65pub struct DefaultDocumentContext;
66
67impl DocumentContext for DefaultDocumentContext {
68 fn resolve_reference(&self, _reference: &str, _base: &str) -> Option<String> {
69 None
70 }
71}