fortrangoingonforty/facsimile / 3c9948a

Browse files

Bump version to 0.9.5

- Fix LSP server installer crash: exit raw mode before execute_command_line
- Add cmdstat parameter to prevent Fortran runtime errors on command failure
- Switch Python LSP installs from pip to pipx for isolated environments
Authored by espadonne
SHA
3c9948a10cdf1ad6e5bd012ba345e7532fe71aa7
Parents
d27a852
Tree
6e80e30

5 changed files

StatusFile+-
M .gitignore 1 0
M VERSION 1 1
M src/lsp/server_detection_module.f90 4 4
M src/lsp/server_installer_module.f90 32 4
M src/version_module.f90 1 1
.gitignoremodified
@@ -11,3 +11,4 @@ fac_debug.txt
11
 # Scratch/notes
11
 # Scratch/notes
12
 old/
12
 old/
13
 CLAUDE.md
13
 CLAUDE.md
14
+CLAUDE.md
VERSIONmodified
@@ -1,1 +1,1 @@
1
-0.9.4
1
+0.9.5
src/lsp/server_detection_module.f90modified
@@ -51,7 +51,7 @@ contains
51
         ! Python - Pyright
51
         ! Python - Pyright
52
         servers(i)%name = 'pyright'
52
         servers(i)%name = 'pyright'
53
         servers(i)%language = 'Python'
53
         servers(i)%language = 'Python'
54
-        servers(i)%install_cmd = 'pip install pyright'
54
+        servers(i)%install_cmd = 'pipx install pyright'
55
         servers(i)%description = 'Python type checker and language server'
55
         servers(i)%description = 'Python type checker and language server'
56
         servers(i)%check_cmd = 'pyright-langserver'
56
         servers(i)%check_cmd = 'pyright-langserver'
57
         i = i + 1
57
         i = i + 1
@@ -59,7 +59,7 @@ contains
59
         ! Python - Ruff
59
         ! Python - Ruff
60
         servers(i)%name = 'ruff'
60
         servers(i)%name = 'ruff'
61
         servers(i)%language = 'Python'
61
         servers(i)%language = 'Python'
62
-        servers(i)%install_cmd = 'pip install ruff'
62
+        servers(i)%install_cmd = 'pipx install ruff'
63
         servers(i)%description = 'Fast Python linter with auto-fix'
63
         servers(i)%description = 'Fast Python linter with auto-fix'
64
         servers(i)%check_cmd = 'ruff'
64
         servers(i)%check_cmd = 'ruff'
65
         i = i + 1
65
         i = i + 1
@@ -67,7 +67,7 @@ contains
67
         ! Python - python-lsp-server
67
         ! Python - python-lsp-server
68
         servers(i)%name = 'python-lsp-server'
68
         servers(i)%name = 'python-lsp-server'
69
         servers(i)%language = 'Python'
69
         servers(i)%language = 'Python'
70
-        servers(i)%install_cmd = 'pip install python-lsp-server'
70
+        servers(i)%install_cmd = 'pipx install python-lsp-server'
71
         servers(i)%description = 'Python LSP (pylsp) with plugins support'
71
         servers(i)%description = 'Python LSP (pylsp) with plugins support'
72
         servers(i)%check_cmd = 'pylsp'
72
         servers(i)%check_cmd = 'pylsp'
73
         i = i + 1
73
         i = i + 1
@@ -203,7 +203,7 @@ contains
203
         ! Fortran - fortls
203
         ! Fortran - fortls
204
         servers(i)%name = 'fortls'
204
         servers(i)%name = 'fortls'
205
         servers(i)%language = 'Fortran'
205
         servers(i)%language = 'Fortran'
206
-        servers(i)%install_cmd = 'pip install fortls'
206
+        servers(i)%install_cmd = 'pipx install fortls'
207
         servers(i)%description = 'Fortran language server'
207
         servers(i)%description = 'Fortran language server'
208
         servers(i)%check_cmd = 'fortls'
208
         servers(i)%check_cmd = 'fortls'
209
     end subroutine init_known_servers
209
     end subroutine init_known_servers
src/lsp/server_installer_module.f90modified
@@ -1,4 +1,6 @@
1
 module server_installer_module
1
 module server_installer_module
2
+    use raw_mode_module, only: disable_raw_mode, enable_raw_mode
3
+    use terminal_io_module, only: terminal_clear_screen, terminal_show_cursor
2
     implicit none
4
     implicit none
3
     private
5
     private
4
 
6
 
@@ -16,7 +18,8 @@ contains
16
     function run_install_command(command) result(result)
18
     function run_install_command(command) result(result)
17
         character(len=*), intent(in) :: command
19
         character(len=*), intent(in) :: command
18
         type(install_result_t) :: result
20
         type(install_result_t) :: result
19
-        integer :: exit_status
21
+        integer :: exit_status, cmd_status
22
+        logical :: raw_disabled
20
 
23
 
21
         result%success = .false.
24
         result%success = .false.
22
         result%exit_code = -1
25
         result%exit_code = -1
@@ -27,9 +30,27 @@ contains
27
             return
30
             return
28
         end if
31
         end if
29
 
32
 
30
-        ! Execute the command
33
+        ! Must exit raw mode before running external commands
31
-        ! Note: This runs synchronously and blocks until complete
34
+        ! Otherwise child process inherits broken terminal state
32
-        call execute_command_line(trim(command), wait=.true., exitstat=exit_status)
35
+        raw_disabled = disable_raw_mode()
36
+
37
+        ! Show cursor and clear screen for command output
38
+        call terminal_show_cursor()
39
+        call terminal_clear_screen()
40
+
41
+        ! Execute the command with cmdstat to catch errors gracefully
42
+        ! Without cmdstat, invalid commands cause Fortran runtime errors
43
+        call execute_command_line(trim(command), wait=.true., exitstat=exit_status, cmdstat=cmd_status)
44
+
45
+        ! Re-enable raw mode for editor
46
+        raw_disabled = enable_raw_mode()
47
+
48
+        ! Check for command execution errors (cmdstat /= 0 means execute failed)
49
+        if (cmd_status /= 0) then
50
+            result%exit_code = cmd_status
51
+            result%message = 'Failed to execute command (cmdstat=' // trim(itoa(cmd_status)) // ')'
52
+            return
53
+        end if
33
 
54
 
34
         result%exit_code = exit_status
55
         result%exit_code = exit_status
35
         result%success = (exit_status == 0)
56
         result%success = (exit_status == 0)
@@ -41,4 +62,11 @@ contains
41
         end if
62
         end if
42
     end function run_install_command
63
     end function run_install_command
43
 
64
 
65
+    ! Simple integer to string helper
66
+    function itoa(i) result(str)
67
+        integer, intent(in) :: i
68
+        character(len=20) :: str
69
+        write(str, '(I0)') i
70
+    end function itoa
71
+
44
 end module server_installer_module
72
 end module server_installer_module
src/version_module.f90modified
@@ -1,4 +1,4 @@
1
 module version_module
1
 module version_module
2
     implicit none
2
     implicit none
3
-    character(len=*), parameter :: VERSION = '0.9.4'
3
+    character(len=*), parameter :: VERSION = '0.9.5'
4
 end module version_module
4
 end module version_module