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

fix for Windows support #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

TimothyGCY
Copy link

LC_ALL seems to be unix environment variable, getting unknown command for Windows machine

@balintkissdev
Copy link

balintkissdev commented Oct 26, 2024

@TimothyGCY Coincidentally I created my own Powershell patch too on my fork because I wanted a Neovim setup on Windows following this guide: https://blog.nikfp.com/how-to-install-and-set-up-neovim-on-windows

Hint: prepending instead can avoid code duplication:

let l:command = 'git -C ' . l:dir_path . ' --no-pager blame --line-porcelain -L ' . a:line_number . ',' . l:end_line . ' -- ' . l:file_path_escaped
if !s:is_windows
  let l:command = 'LC_ALL=C ' . l:command
endif

@balintkissdev
Copy link

balintkissdev commented Oct 26, 2024

Closes #50

@balintkissdev
Copy link

@APZelos @georgesofianosgr Tested @TimothyGCY 's fix on Windows 10 + PowerShell 7.4.6 + Terminal Preview.

calling blamer#GetMessages('E:/PROGRAMMING/OPEN_SOURCE/blamer.nvim/autoload/blamer.vim', 1, 1)

line 1:   let l:dir_path = shellescape(s:substitute_path_separator(expand('%:h')))
calling <SNR>15_substitute_path_separator('E:/PROGRAMMING/OPEN_SOURCE/blamer.nvim/autoload')

line 1:   return s:is_windows ? substitute(a:path, '\\', '/', 'g') : a:path
<SNR>15_substitute_path_separator returning 'E:/PROGRAMMING/OPEN_SOURCE/blamer.nvim/autoload'

continuing in blamer#GetMessages

line 2:   let l:end_line = a:line_number + a:line_count - 1
line 3:   let l:file_path_escaped = shellescape(a:file)
line 4:   let l:command = 'git -C ' . l:dir_path . ' --no-pager blame --line-porcelain -L ' . a:line_number . ',' . l:end_line . ' -- ' . l:file_path_escaped
line 5:   let l:result = system(l:command)
Executing command: "'cmd.exe' '/s' '/c' '"git -C "E:/PROGRAMMING/OPEN_SOURCE/blamer.nvim/autoload" --no-pager blame --line-porcelain -L 1,1 -- "E:/PROGRAMMING/OPEN_SOURCE/blamer.nvim/autoload/blamer.vim""'"

Tested on Ubuntu on Windows Subsystem for Linux (WSL):

calling blamer#GetMessages('/home/bkiss/dotfiles/.config/nvim/init.lua', 1, 1)

line 1:   let l:dir_path = shellescape(s:substitute_path_separator(expand('%:h')))
calling <SNR>9_substitute_path_separator('/home/bkiss/dotfiles/.config/nvim')

line 1:   return s:is_windows ? substitute(a:path, '\\', '/', 'g') : a:path
<SNR>9_substitute_path_separator returning '/home/bkiss/dotfiles/.config/nvim'

continuing in blamer#GetMessages

line 2:   let l:end_line = a:line_number + a:line_count - 1
line 3:   let l:file_path_escaped = shellescape(a:file)
line 4:   let l:command = 'LC_ALL=C git -C ' . l:dir_path . ' --no-pager blame --line-porcelain -L ' . a:line_number . ',' . l:end_line . ' -- ' . l:file_path_escaped
line 5:   let l:result = system(l:command)
Executing command: "'/bin/bash' '-c' 'LC_ALL=C git -C '/home/bkiss/dotfiles/.config/nvim' --no-pager blame --line-porcelain -L 1,1 -- '/home/bkiss/dotfiles/.config/nvim/init.lua''"

Both are working.

@TimothyGCY
Copy link
Author

@TimothyGCY Coincidentally I created my own Powershell patch too on my fork because I wanted a Neovim setup on Windows following this guide: https://blog.nikfp.com/how-to-install-and-set-up-neovim-on-windows

Hint: prepending instead can avoid code duplication:


let l:command = 'git -C ' . l:dir_path . ' --no-pager blame --line-porcelain -L ' . a:line_number . ',' . l:end_line . ' -- ' . l:file_path_escaped

if !s:is_windows

  let l:command = 'LC_ALL=C ' . l:command

endif

That's good for me to learn about proper way of string manipulation in Lua

Lua may not be my day-to-day used language, so I just did it in the simplest way I could understand.

Thanks buddy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants