Skip to content

Commit

Permalink
update lspconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiwen Wang committed Aug 1, 2022
1 parent d405698 commit deb9395
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 33 deletions.
6 changes: 0 additions & 6 deletions lua/custom/chadrc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ local override = require "custom.override"

M.plugins = {

options = {
lspconfig = {
setup_lspconf = "custom.plugins.lspconfig",
},
},

override = {
["kyazdani42/nvim-tree.lua"] = override.nvimtree,
["nvim-treesitter/nvim-treesitter"] = override.treesitter,
Expand Down
31 changes: 31 additions & 0 deletions lua/custom/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,35 @@ return {
require "custom.plugins.project"
end,
},

["neovim/nvim-lspconfig"] = {
config = function()
require "plugins.configs.lspconfig"
require "custom.plugins.lspconfig"
end,
},

["williamboman/mason.nvim"] = {
ensure_installed = {
-- lua stuff
"lua-language-server",
"stylua",

-- tool dev
"json-lsp",

-- shell
"shfmt",
"shellcheck",

-- c/c++
"clangd",

-- python
"pyright",

-- cmake
"cmake-language-server",
},
},
}
35 changes: 8 additions & 27 deletions lua/custom/plugins/lspconfig.lua
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
local M = {}
local on_attach = require("plugins.configs.lspconfig").on_attach
local capabilities = require("plugins.configs.lspconfig").capabilities

M.setup_lsp = function(attach, capabilities)
local lspconfig = require "lspconfig"
local lspconfig = require "lspconfig"
local servers = { "bashls", "clangd", "pyright", "cmake"}

local servers = { "bashls", "clangd", "pyright", "cmake"}

for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = attach,
capabilities = capabilities,
root_dir = vim.loop.cwd,
}
end

-- temporarily disable tsserver suggestions
require("lspconfig").tsserver.setup {
init_options = {
preferences = {
disableSuggestions = true,
},
},

on_attach = function(client, bufnr)
client.resolved_capabilities.document_formatting = false
vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>fm", "<cmd>lua vim.lsp.buf.formatting()<CR>", {})
end,
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
}
end

return M

0 comments on commit deb9395

Please sign in to comment.