nvim
This commit is contained in:
		
							parent
							
								
									38fc909733
								
							
						
					
					
						commit
						0f6fc5bd2f
					
				
					 1 changed files with 19 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -4,6 +4,14 @@ if not ok then
 | 
			
		|||
    return
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local root_dir
 | 
			
		||||
for dir in vim.fs.parents(vim.api.nvim_buf_get_name(0)) do
 | 
			
		||||
    if vim.fn.isdirectory(dir .. "/.git") == 1 then
 | 
			
		||||
        root_dir = dir
 | 
			
		||||
        break
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local border = {
 | 
			
		||||
    { "┌", "FloatBorder" },
 | 
			
		||||
    { "─", "FloatBorder" },
 | 
			
		||||
| 
						 | 
				
			
			@ -64,8 +72,16 @@ local on_attach = function(client, bufnr)
 | 
			
		|||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function prettier_command()
 | 
			
		||||
    if vim.fs.basename(root_dir .. "node_modules/prettier") then
 | 
			
		||||
        return "npx prettier"
 | 
			
		||||
    else
 | 
			
		||||
        return "prettier"
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local prettier = {
 | 
			
		||||
    formatCommand = [[prettier --stdin-filepath ${INPUT} ${--tab-width:tab_width}]],
 | 
			
		||||
    formatCommand = prettier_command() .. [[ --stdin-filepath ${INPUT} ${--tab-width:tab_width}]],
 | 
			
		||||
    formatStdin = true,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -92,7 +108,7 @@ local shellcheck = {
 | 
			
		|||
 | 
			
		||||
local servers = {
 | 
			
		||||
    efm = {
 | 
			
		||||
        filetypes = { "typescript", "typescriptreact", "sh" },
 | 
			
		||||
        filetypes = { "typescript", "typescriptreact", "sh", "php" },
 | 
			
		||||
        init_options = { documentFormatting = true },
 | 
			
		||||
        settings = {
 | 
			
		||||
            rootMarkers = { ".git/" },
 | 
			
		||||
| 
						 | 
				
			
			@ -100,6 +116,7 @@ local servers = {
 | 
			
		|||
                typescript = { prettier, eslint },
 | 
			
		||||
                typescriptreact = { prettier, eslint },
 | 
			
		||||
                sh = { shellcheck },
 | 
			
		||||
                php = { prettier },
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue