fix rails setup
This commit is contained in:
parent
1f2f336b64
commit
f3d84f90cd
6 changed files with 87 additions and 81 deletions
|
|
@ -9,14 +9,6 @@ lsp.ensure_installed({
|
|||
"rust_analyzer",
|
||||
})
|
||||
|
||||
-- see documentation of null-null-ls for more configuration options!
|
||||
local mason_nullls = require("mason-null-ls")
|
||||
mason_nullls.setup({
|
||||
automatic_installation = true,
|
||||
automatic_setup = true,
|
||||
})
|
||||
mason_nullls.setup_handlers({})
|
||||
|
||||
local Remap = require("rahcodes.keymap")
|
||||
local nnoremap = Remap.nnoremap
|
||||
local inoremap = Remap.inoremap
|
||||
|
|
@ -32,10 +24,30 @@ local cmp_mappings = lsp.defaults.cmp_mappings({
|
|||
["<C-y>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
})
|
||||
|
||||
lsp.setup_nvim_cmp({
|
||||
mapping = cmp_mappings,
|
||||
})
|
||||
|
||||
lsp.configure("solargraph", {
|
||||
settings = {
|
||||
solargraph = {
|
||||
diagnostics = false,
|
||||
},
|
||||
},
|
||||
on_attach = function()
|
||||
print("hello solargraph")
|
||||
end,
|
||||
})
|
||||
|
||||
lsp.configure("sumneko_lua", {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = { globals = { "vim" } },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
lsp.on_attach = function(client, bufnr)
|
||||
-- Disable LSP server formatting, to prevent formatting twice.
|
||||
-- Once by the LSP server, second time by NULL-ls.
|
||||
|
|
@ -110,3 +122,10 @@ lsp.on_attach = function(client, bufnr)
|
|||
end
|
||||
|
||||
lsp.setup()
|
||||
|
||||
local mason_nullls = require("mason-null-ls")
|
||||
mason_nullls.setup({
|
||||
automatic_installation = true,
|
||||
automatic_setup = true,
|
||||
})
|
||||
mason_nullls.setup_handlers({})
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
local mason_status, mason = pcall(require, "mason")
|
||||
if not mason_status then
|
||||
return
|
||||
end
|
||||
|
||||
local mason_lspconfig_status, mason_lspconfig = pcall(require, "mason-lspconfig")
|
||||
if not mason_lspconfig_status then
|
||||
return
|
||||
end
|
||||
|
||||
local mason_null_ls_status, mason_null_ls = pcall(require, "mason-null-ls")
|
||||
if not mason_null_ls_status then
|
||||
return
|
||||
end
|
||||
|
||||
mason.setup()
|
||||
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = {
|
||||
"tsserver",
|
||||
"html",
|
||||
"cssls",
|
||||
"sumneko_lua",
|
||||
},
|
||||
})
|
||||
|
||||
mason_null_ls.setup({
|
||||
ensure_installed = {
|
||||
"prettier",
|
||||
"stylua",
|
||||
"eslint_d",
|
||||
},
|
||||
})
|
||||
|
|
@ -4,15 +4,37 @@ if not setup then
|
|||
end
|
||||
|
||||
local formatting = null_ls.builtins.formatting
|
||||
local diagnostics = null_ls.builtins.diagnostics
|
||||
local conditional = function(fn)
|
||||
local utils = require("null-ls.utils").make_conditional_utils()
|
||||
return fn(utils)
|
||||
end
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
formatting.prettier,
|
||||
formatting.stylua,
|
||||
diagnostics.eslint_d,
|
||||
diagnostics.rubocop,
|
||||
|
||||
-- Here we set a conditional to call the rubocop formatter. If we have a Gemfile in the project, we call "bundle exec rubocop", if not we only call "rubocop".
|
||||
conditional(function(utils)
|
||||
return utils.root_has_file("Gemfile")
|
||||
and null_ls.builtins.formatting.rubocop.with({
|
||||
command = "bundle",
|
||||
args = vim.list_extend({ "exec", "rubocop" }, null_ls.builtins.formatting.rubocop._opts.args),
|
||||
})
|
||||
or null_ls.builtins.formatting.rubocop
|
||||
end),
|
||||
|
||||
-- Same as above, but with diagnostics.rubocop to make sure we use the proper rubocop version for the project
|
||||
conditional(function(utils)
|
||||
return utils.root_has_file("Gemfile")
|
||||
and null_ls.builtins.diagnostics.rubocop.with({
|
||||
command = "bundle",
|
||||
args = vim.list_extend({ "exec", "rubocop" }, null_ls.builtins.diagnostics.rubocop._opts.args),
|
||||
})
|
||||
or null_ls.builtins.diagnostics.rubocop
|
||||
end),
|
||||
},
|
||||
-- format on save
|
||||
on_attach = function(client, bufnr)
|
||||
|
|
@ -22,7 +44,6 @@ null_ls.setup({
|
|||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
-- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
|
||||
vim.lsp.buf.format({ bufnr = bufnr, timeout_ms = 10000 })
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ vim.keymap.set("n", "<leader>fh", builtin.help_tags, {})
|
|||
|
||||
vim.keymap.set("n", "<leader>m", builtin.oldfiles, {})
|
||||
vim.keymap.set("n", "<leader>gb", builtin.git_branches, {})
|
||||
-- vim.keymap.set('n', '<leader>gs', builtin.git_status, {})
|
||||
vim.keymap.set("n", "<leader><leader>", builtin.git_files, {})
|
||||
vim.keymap.set("n", "<leader>ps", function()
|
||||
builtin.grep_string({ search = vim.fn.input("Grep > ") })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue