lsp workspace stuff (#1677)

* some lsp shit

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* more stuffs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* on open send close and open events

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* update the path

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* send on close

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* on close project

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* update on close

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* initpromise

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add to wasm.ts

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* Update src/lang/wasm.ts

Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>

* restart lsps on failure

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add panic hook

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updartes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch>
This commit is contained in:
Jess Frazelle
2024-03-11 17:50:31 -07:00
committed by GitHub
parent cd158f8db0
commit db5657a298
17 changed files with 436 additions and 137 deletions

View File

@ -15,11 +15,20 @@ import { FILE_EXT, sortProject } from 'lib/tauriFS'
import { CustomIcon } from './CustomIcon'
import { kclManager } from 'lang/KclSingleton'
import { useDocumentHasFocus } from 'hooks/useDocumentHasFocus'
import { useLspContext } from './LspProvider'
function getIndentationCSS(level: number) {
return `calc(1rem * ${level + 1})`
}
// an OS-agnostic way to get the basename of the path.
export function basename(path: string): string {
// Regular expression to match the last portion of the path, taking into account both POSIX and Windows delimiters
const re = /[^\\/]+$/
const match = path.match(re)
return match ? match[0] : ''
}
function RenameForm({
fileOrDir,
setIsRenaming,
@ -147,6 +156,7 @@ const FileTreeItem = ({
level?: number
}) => {
const { send, context } = useFileContext()
const { lspClients } = useLspContext()
const navigate = useNavigate()
const [isRenaming, setIsRenaming] = useState(false)
const [isConfirmingDelete, setIsConfirmingDelete] = useState(false)
@ -174,6 +184,28 @@ const FileTreeItem = ({
kclManager.code
)
} else {
// Let the lsp servers know we closed a file.
const currentFilePath = basename(currentFile?.path || 'main.kcl')
lspClients.forEach((lspClient) => {
lspClient.textDocumentDidClose({
textDocument: {
uri: `file:///${currentFilePath}`,
},
})
})
const newFilePath = basename(fileOrDir.path)
// Then let the clients know we opened a file.
lspClients.forEach((lspClient) => {
lspClient.textDocumentDidOpen({
textDocument: {
uri: `file:///${newFilePath}`,
languageId: 'kcl',
version: 1,
text: '',
},
})
})
// Open kcl files
navigate(`${paths.FILE}/${encodeURIComponent(fileOrDir.path)}`)
}