dotfiles-public icon indicating copy to clipboard operation
dotfiles-public copied to clipboard

I have been able to fix several problems, however even the nvim is not 100%,

Open MrShortcut opened this issue 2 years ago • 6 comments

I have been able to fix several problems, however even the nvim is not 100%,

  • I was able to fix lsp to detect the syntax.... -> TSinstall html css javascript,
  • I was able to fix guibg -> bg errors.... -> modify lua file configs.
  • lsp finder not working 100%
  • prettier autoformatter doesn't work in any of my environments.

tested on windows 11 and ubuntu WSL.

check my fixes and more mappings.

https://github.com/MrShortcut/nvim

MrShortcut avatar Aug 19 '22 15:08 MrShortcut

In my case I've added more builtin formatter in null-ls setting and they're working well.

null_ls.setup({
	sources = {
		-- Python
		null_ls.builtins.formatting.isort.with({
			extra_args = { "--line-length", "79", "--profile", "black" },
		}),
		null_ls.builtins.formatting.black.with({
			extra_args = { "--line-length", "79" },
		}),
		null_ls.builtins.diagnostics.flake8.with({ filetypes = { "python" } }),

		-- refactoring
		-- null_ls.builtins.code_actions.refactoring.with({ filetypes = { "python" } }),
		-- Lua
		null_ls.builtins.formatting.stylua.with({ filetypes = { "lua" } }),
		-- Spell checking
		-- null_ls.builtins.diagnostics.codespell.with({
		--     args = { "--builtin", "clear,rare,code", "-" },
		-- }),
	},
	on_attach = function(client, bufnr)
		if client.server_capabilities.documentFormattingProvider then
			vim.api.nvim_clear_autocmds({ buffer = 0, group = augroup_format })
			vim.api.nvim_create_autocmd("BufWritePre", {
				group = augroup_format,
				buffer = 0,
				callback = function()
					vim.lsp.buf.formatting_seq_sync(nill, 10000)
				end,
			})
		end
	end,
})

here :https://github.com/Frozatquadtine/nvim/blob/main/plugin/null-ls.lua

vazw avatar Sep 26 '22 12:09 vazw

I also have trouble with Prettier not being run when saving, however the :Prettier command works fine. Did you manage to get it working ?

remy-poirier avatar Oct 04 '22 09:10 remy-poirier

ok finally I thank I make it worked by "simply" adding this line to my null_ls.rc.lua (into sources)

null_ls.builtins.formatting.prettier

remy-poirier avatar Oct 04 '22 09:10 remy-poirier

@remy-poirier, would you mind sharing that part of your setup, that runs null_ls.builtins.formatting.prettier on save? 🙏

I still cannot get it working, I'm still not very fluent with lsp configurations..

Thanks!

bfulop avatar Oct 04 '22 13:10 bfulop

I'm really not fluent with lsp at all, to be honest I didn't knew anything about this language before yesterday, when I watched Takuya's video.

I will share you some of my files:

after/plugin/prettier.rc.lua

local prettier = require("prettier")

prettier.setup({
  bin = 'prettierd', -- or `'prettierd'` (v0.22+)
  filetypes = {
    "css",
    "graphql",
    "html",
    "javascript",
    "javascriptreact",
    "json",
    "less",
    "markdown",
    "scss",
    "typescript",
    "typescriptreact",
    "yaml",
  }
})

plugin/null-ls.rc.lua

local status, null_ls = pcall(require, "null-ls")
if (not status) then return end

local augroup_format = vim.api.nvim_create_augroup("Format", { clear = true })

null_ls.setup {
  sources = {
    null_ls.builtins.diagnostics.eslint_d.with({
      diagnostics_format = '[eslint] #{m}\n(#{c})'
    }),
    null_ls.builtins.diagnostics.fish,
    null_ls.builtins.formatting.stylua.with({ filetypes = { "lua" } }),
    null_ls.builtins.formatting.prettier
  },
  on_attach = function(client, bufnr)
    if client.server_capabilities.documentFormattingProvider then
      vim.api.nvim_clear_autocmds { buffer = 0, group = augroup_format }
      vim.api.nvim_create_autocmd("BufWritePre", {
        group = augroup_format,
        buffer = 0,
        callback = function() vim.lsp.buf.formatting_seq_sync(nil, 10000) end
      })
    end
  end
}

I hope this helped you

PS: I cannot explain any of these lines :D

remy-poirier avatar Oct 04 '22 13:10 remy-poirier

Thank you @remy-poirier for sharing your setup! I added it to my config and it seems to work well, Prettier is now used to format my files on save!

bfulop avatar Oct 06 '22 07:10 bfulop