summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseth <[email protected]>2022-08-24 15:37:06 -0400
committerseth <[email protected]>2022-08-24 15:37:06 -0400
commit8fef927ede6733c20a53c4b0c13d2ab4cb08b604 (patch)
treec5eae97847773355ffd3f2afcc84c7c9c2a5b387
parentee45c4211d79dfb3b62531cc4f974ac3932e5131 (diff)
refactor lsp config
-rw-r--r--.config/nvim/lua/getchoo/.stylua.toml2
-rw-r--r--.config/nvim/lua/getchoo/ftdetect.lua2
-rw-r--r--.config/nvim/lua/getchoo/lsp/config.lua117
-rw-r--r--.config/nvim/lua/getchoo/lsp/config/cmp.lua71
-rw-r--r--.config/nvim/lua/getchoo/lsp/config/init.lua34
-rw-r--r--.config/nvim/lua/getchoo/lsp/config/lsp_config.lua42
-rw-r--r--.config/nvim/lua/getchoo/lsp/config/mason.lua14
-rw-r--r--.config/nvim/lua/getchoo/lsp/config/null_ls.lua38
-rw-r--r--.config/nvim/lua/getchoo/lsp/config/sources.lua27
-rw-r--r--.config/nvim/lua/getchoo/lsp/server.lua4
-rw-r--r--.config/nvim/lua/getchoo/plugins.lua31
11 files changed, 259 insertions, 123 deletions
diff --git a/.config/nvim/lua/getchoo/.stylua.toml b/.config/nvim/lua/getchoo/.stylua.toml
new file mode 100644
index 0000000..0435f67
--- /dev/null
+++ b/.config/nvim/lua/getchoo/.stylua.toml
@@ -0,0 +1,2 @@
+indent_type = "Spaces"
+indent_width = 2
diff --git a/.config/nvim/lua/getchoo/ftdetect.lua b/.config/nvim/lua/getchoo/ftdetect.lua
index d12b9c2..1386cf2 100644
--- a/.config/nvim/lua/getchoo/ftdetect.lua
+++ b/.config/nvim/lua/getchoo/ftdetect.lua
@@ -1,6 +1,4 @@
---
-- load custom file types
---
vim.g.do_filetype_lua = 1 -- enable filetype.lua
vim.g.did_load_filetypes = 0
diff --git a/.config/nvim/lua/getchoo/lsp/config.lua b/.config/nvim/lua/getchoo/lsp/config.lua
deleted file mode 100644
index 60ece4d..0000000
--- a/.config/nvim/lua/getchoo/lsp/config.lua
+++ /dev/null
@@ -1,117 +0,0 @@
---
--- config for lsp server
---
-local null_ls = require("null-ls")
-local diagnostics = null_ls.builtins.diagnostics
-local formatting = null_ls.builtins.formatting
-
-local M = {}
-
-vim.g.coq_settings = { auto_start = "shut-up" }
-
-local sources = {
- lsp_servers = { "rust_analyzer", "pyright", "bashls" },
- null_ls = {
- diagnostics.alex,
- diagnostics.codespell,
- diagnostics.flake8,
- formatting.black,
- formatting.codespell,
- formatting.prettier,
- formatting.rustfmt,
- formatting.stylua,
- },
- mason = {
- "alex",
- "black",
- "codespell",
- "flake8",
- "prettier",
- "stylua",
- },
-}
-
--- configure lsp servers
-local all_config = {}
-local servers = {}
-for _, server in ipairs(sources.lsp_servers) do
- servers[server] = all_config
-end
-
-servers["sumneko_lua"] = {
- settings = {
- Lua = {
- runtime = {
- version = "LuaJIT",
- },
- diagnostics = {
- globals = { "vim" },
- },
- workspace = {
- library = vim.api.nvim_get_runtime_file("", true),
- },
- telemetry = {
- enable = false,
- },
- },
- },
-}
-
-M.lsp_servers = servers
-
--- only use null-ls for formatting
-
---- for neovim >= 8
---- local lsp_formatting = function(bufnr)
---- vim.lsp.buf.format({
---- filter = function(client)
---- return client.name == "null-ls"
---- end,
---- bufnr = bufnr,
---- })
---- end
-
-local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
-local on_attach = function(client, bufnr)
- if client.supports_method("textDocument/formatting") then
- vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
- vim.api.nvim_create_autocmd("BufWritePre", {
- group = augroup,
- buffer = bufnr,
- callback = function()
- local params = require("vim.lsp.util").make_formatting_params({})
- client.request("textDocument/formatting", params, nil, bufnr)
- -- lsp_formatting(bufnr) -- neovim >= 8
- end,
- })
- end
-end
-
-M.null_ls = {
- on_attach = on_attach,
- sources = sources.null_ls,
-}
-
-M.mason_tool_installer = {
- ensure_installed = sources.mason,
-}
-
-M.mason_lsp = {
- automatic_installation = true,
-}
-
--- etc plugins
-M.bufferline = {
- options = {
- numbers = "ordinal",
- diagnostics = "nvim_lsp",
- always_show_bufferline = false,
- },
-}
-M.tree = {}
-M.treesitter = {
- auto_install = true,
-}
-M.trouble = {}
-
-return M
diff --git a/.config/nvim/lua/getchoo/lsp/config/cmp.lua b/.config/nvim/lua/getchoo/lsp/config/cmp.lua
new file mode 100644
index 0000000..bfade29
--- /dev/null
+++ b/.config/nvim/lua/getchoo/lsp/config/cmp.lua
@@ -0,0 +1,71 @@
+local cmp = require("cmp")
+local mapping = cmp.mapping
+local luasnip = require("luasnip")
+
+local M = {}
+
+local has_words_before = function()
+ local line, col = unpack(vim.api.nvim_win_get_cursor(0))
+ return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
+end
+
+local feedkey = function(key, mode)
+ vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
+end
+
+M.config = {
+ snippet = {
+ expand = function(args)
+ vim.fn["vsnip#anonymous"](args.body)
+ luasnip.lsp_expand(args.body)
+ end,
+ },
+ mapping = mapping.preset.insert({
+ ["<C-Space>"] = mapping.complete(),
+ ["<CR>"] = mapping.confirm({
+ select = true,
+ }),
+ ["<Tab>"] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_next_item()
+ elseif luasnip.expand_or_jumpable() then
+ luasnip.expand_or_jump()
+ elseif vim.fn["vsnip#available"](1) == 1 then
+ feedkey("<Plug>(vsnip-expand-or-jump)", "")
+ elseif has_words_before() then
+ cmp.complete()
+ else
+ fallback()
+ end
+ end, { "i", "s" }),
+ ["<S-Tab>"] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_prev_item()
+ elseif luasnip.jumpable(-1) then
+ luasnip.jump(-1)
+ elseif vim.fn["vsnip#available"](-1) == 1 then
+ feedkey("<Plug>(vsnip-jump-prev)", "")
+ else
+ fallback()
+ end
+ end, { "i", "s" }),
+ }),
+ sources = cmp.config.sources({
+ { name = "nvim_lsp" },
+ { name = "luasnip" },
+ { name = "vsnip" },
+ }, {
+ { name = "buffer" },
+ }),
+}
+
+local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
+capabilities.textDocument.completion.completionItem.snippetSupport = true
+
+M.capabilities = capabilities
+
+M.on_attach = function(_, bufnr)
+ vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
+end
+
+return M
diff --git a/.config/nvim/lua/getchoo/lsp/config/init.lua b/.config/nvim/lua/getchoo/lsp/config/init.lua
new file mode 100644
index 0000000..b136dcf
--- /dev/null
+++ b/.config/nvim/lua/getchoo/lsp/config/init.lua
@@ -0,0 +1,34 @@
+-- wrapper for all configs
+local cmp = require("getchoo.lsp.config.cmp")
+local lsp_config = require("getchoo.lsp.config.lsp_config")
+local mason = require("getchoo.lsp.config.mason")
+local null_ls = require("getchoo.lsp.config.null_ls")
+
+local M = {}
+
+M.bufferline = {
+ options = {
+ numbers = "ordinal",
+ diagnostics = "nvim_lsp",
+ always_show_bufferline = false,
+ },
+}
+
+M.cmp = cmp.config
+
+M.lsp_servers = lsp_config.servers
+
+M.mason_tool_installer = mason.mason_tool_installer
+M.mason_lsp = mason.mason_lsp_config
+
+M.null_ls = null_ls.config
+
+M.tree = {}
+
+M.treesitter = {
+ auto_install = true,
+}
+
+M.trouble = {}
+
+return M
diff --git a/.config/nvim/lua/getchoo/lsp/config/lsp_config.lua b/.config/nvim/lua/getchoo/lsp/config/lsp_config.lua
new file mode 100644
index 0000000..4bf69e4
--- /dev/null
+++ b/.config/nvim/lua/getchoo/lsp/config/lsp_config.lua
@@ -0,0 +1,42 @@
+local cmp = require("getchoo.lsp.config.cmp")
+local sources = require("getchoo.lsp.config.sources")
+
+local M = {}
+
+local on_attach = function(client, bufnr)
+ cmp.on_attach(client, bufnr)
+end
+
+local all_config = {
+ on_attach = on_attach,
+ capabilities = cmp.capabilities,
+}
+
+local servers = {}
+for _, server in ipairs(sources.lsp_servers) do
+ servers[server] = all_config
+end
+
+servers["sumneko_lua"] = {
+ on_attach = on_attach,
+ settings = {
+ Lua = {
+ runtime = {
+ version = "LuaJIT",
+ },
+ diagnostics = {
+ globals = { "vim" },
+ },
+ workspace = {
+ library = vim.api.nvim_get_runtime_file("", true),
+ },
+ telemetry = {
+ enable = false,
+ },
+ },
+ },
+}
+
+M.servers = servers
+
+return M
diff --git a/.config/nvim/lua/getchoo/lsp/config/mason.lua b/.config/nvim/lua/getchoo/lsp/config/mason.lua
new file mode 100644
index 0000000..de45c49
--- /dev/null
+++ b/.config/nvim/lua/getchoo/lsp/config/mason.lua
@@ -0,0 +1,14 @@
+-- config for mason tools
+local sources = require("getchoo.lsp.config.sources")
+
+local M = {}
+
+M.mason_tool_installer = {
+ ensure_installed = sources.mason,
+}
+
+M.mason_lsp = {
+ automatic_installation = true,
+}
+
+return M
diff --git a/.config/nvim/lua/getchoo/lsp/config/null_ls.lua b/.config/nvim/lua/getchoo/lsp/config/null_ls.lua
new file mode 100644
index 0000000..dd091a9
--- /dev/null
+++ b/.config/nvim/lua/getchoo/lsp/config/null_ls.lua
@@ -0,0 +1,38 @@
+local sources = require("getchoo.lsp.config.sources")
+
+local M = {}
+
+-- only use null-ls for formatting
+
+--- for neovim >= 8
+--- local lsp_formatting = function(bufnr)
+--- vim.lsp.buf.format({
+--- filter = function(client)
+--- return client.name == "null-ls"
+--- end,
+--- bufnr = bufnr,
+--- })
+--- end
+
+local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
+local formatting_on_attach = function(client, bufnr)
+ if client.supports_method("textDocument/formatting") then
+ vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
+ vim.api.nvim_create_autocmd("BufWritePre", {
+ group = augroup,
+ buffer = bufnr,
+ callback = function()
+ local params = require("vim.lsp.util").make_formatting_params({})
+ client.request("textDocument/formatting", params, nil, bufnr)
+ -- lsp_formatting(bufnr) -- neovim >= 8
+ end,
+ })
+ end
+end
+
+M.config = {
+ on_attach = formatting_on_attach,
+ sources = sources.null_ls,
+}
+
+return M
diff --git a/.config/nvim/lua/getchoo/lsp/config/sources.lua b/.config/nvim/lua/getchoo/lsp/config/sources.lua
new file mode 100644
index 0000000..7281508
--- /dev/null
+++ b/.config/nvim/lua/getchoo/lsp/config/sources.lua
@@ -0,0 +1,27 @@
+local null_ls = require("null-ls")
+local diagnostics = null_ls.builtins.diagnostics
+local formatting = null_ls.builtins.formatting
+
+local M = {
+ lsp_servers = { "rust_analyzer", "pyright", "bashls" },
+ null_ls = {
+ diagnostics.alex,
+ diagnostics.codespell,
+ diagnostics.flake8,
+ formatting.black,
+ formatting.codespell,
+ formatting.prettier,
+ formatting.rustfmt,
+ formatting.stylua,
+ },
+ mason = {
+ "alex",
+ "black",
+ "codespell",
+ "flake8",
+ "prettier",
+ "stylua",
+ },
+}
+
+return M
diff --git a/.config/nvim/lua/getchoo/lsp/server.lua b/.config/nvim/lua/getchoo/lsp/server.lua
index 2935a9c..2aae4da 100644
--- a/.config/nvim/lua/getchoo/lsp/server.lua
+++ b/.config/nvim/lua/getchoo/lsp/server.lua
@@ -2,6 +2,7 @@
-- initialize lsp servers
--
+local cmp = require("cmp")
local lspconfig = require("lspconfig")
local null_ls = require("null-ls")
local config = require("getchoo.lsp.config")
@@ -12,7 +13,8 @@ require("mason-tool-installer").setup(config.mason_tool_installer)
vim.opt.runtimepath:append("~/.local/share/nvim/mason/bin/")
for server, settings in pairs(config.lsp_servers) do
- lspconfig[server].setup(require("coq").lsp_ensure_capabilities(settings))
+ lspconfig[server].setup(settings)
end
+cmp.setup(config.cmp)
null_ls.setup(config.null_ls)
diff --git a/.config/nvim/lua/getchoo/plugins.lua b/.config/nvim/lua/getchoo/plugins.lua
index 9e7166f..c5f6075 100644
--- a/.config/nvim/lua/getchoo/plugins.lua
+++ b/.config/nvim/lua/getchoo/plugins.lua
@@ -21,38 +21,63 @@ end
require("packer").startup(function(use)
use("wbthomason/packer.nvim")
+
-- comsetic plugins
use({ "nvim-lualine/lualine.nvim", requires = { "kyazdani42/nvim-web-devicons", opt = true } })
+
use("arcticicestudio/nord-vim")
+
use({ "rose-pine/neovim", as = "rose-pine" })
+
+ use({
+ "goolord/alpha-nvim",
+ config = function()
+ require("alpha").setup(require("alpha.themes.dashboard").config)
+ end,
+ })
+
-- lsp plugins
use("neovim/nvim-lspconfig")
+
use({
"jose-elias-alvarez/null-ls.nvim",
requires = { "nvim-lua/plenary.nvim" },
})
+
use("williamboman/mason.nvim")
use("williamboman/mason-lspconfig")
use("WhoIsSethDaniel/mason-tool-installer.nvim")
+
use({
"nvim-treesitter/nvim-treesitter",
run = function()
require("nvim-treesitter.install").update({ with_sync = true })
end,
})
- use("ms-jpq/coq_nvim")
- use("ms-jpq/coq.artifacts")
- use("ms-jpq/coq.thirdparty")
+
+ use("hrsh7th/cmp-nvim-lsp")
+ use("hrsh7th/cmp-buffer")
+ use("hrsh7th/cmp-path")
+ use("hrsh7th/cmp-cmdline")
+ use("hrsh7th/nvim-cmp")
+ use("hrsh7th/cmp-vsnip")
+ use("hrsh7th/vim-vsnip")
+ use("L3MON4D3/LuaSnip")
+ use("saadparwaiz1/cmp_luasnip")
+
use("kyazdani42/nvim-tree.lua")
+
use({
"akinsho/bufferline.nvim",
tag = "v2.*",
requires = { "kyazdani42/nvim-web-devicons" },
})
+
use({
"folke/trouble.nvim",
requires = { "kyazdani42/nvim-web-devicons" },
})
+
use({
"liuchengxu/vim-clap",
run = function()