Skip to content

Commit

Permalink
feat(lsp): finish lsp configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
felicandalc committed May 25, 2022
1 parent 20c8625 commit 8637fca
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 18 deletions.
9 changes: 6 additions & 3 deletions lua/nn/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ cmp.setup {
}),
},
formatting = {
fields = { "menu", "abbr", "kind" },
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- Kind icons
-- vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
vim_item.menu = ({
nvim_lsp = "[LSP]",
nvim_lua = "[NVIM_LUA",
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
Expand All @@ -109,6 +111,7 @@ cmp.setup {
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "npm" },
{ name = "buffer" },
Expand Down
5 changes: 1 addition & 4 deletions lua/nn/lsp/handlers.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local M = {}

-- TODO: backfill this to template
M.setup = function()
local signs = {
{ name = "DiagnosticSignError", text = "" },
Expand All @@ -14,9 +13,7 @@ M.setup = function()
end

local config = {
-- disable virtual text
virtual_text = false,
-- show signs
signs = {
active = signs,
},
Expand Down Expand Up @@ -76,7 +73,7 @@ local function lsp_keymaps(bufnr)
bufnr,
"n",
"gl",
'<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ border = "rounded" })<CR>',
'<cmd>lua vim.diagnostic.open_float({ border = "rounded" })<CR>',
opts
)
vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', opts)
Expand Down
4 changes: 2 additions & 2 deletions lua/nn/lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ if not status_ok then
return
end

require("user.lsp.lsp-installer")
require("user.lsp.handlers").setup()
require("nn.lsp.lsp-installer")
require("nn.lsp.handlers").setup()
10 changes: 5 additions & 5 deletions lua/nn/lsp/lsp-installer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ end
-- Alternatively, you may also register handlers on specific server instances instead (see example below).
lsp_installer.on_server_ready(function(server)
local opts = {
on_attach = require("user.lsp.handlers").on_attach,
capabilities = require("user.lsp.handlers").capabilities,
on_attach = require("nn.lsp.handlers").on_attach,
capabilities = require("nn.lsp.handlers").capabilities,
}

if server.name == "jsonls" then
local jsonls_opts = require("user.lsp.settings.jsonls")
local jsonls_opts = require("nn.lsp.settings.jsonls")
opts = vim.tbl_deep_extend("force", jsonls_opts, opts)
end

if server.name == "sumneko_lua" then
local sumneko_opts = require("user.lsp.settings.sumneko_lua")
local sumneko_opts = require("nn.lsp.settings.sumneko_lua")
opts = vim.tbl_deep_extend("force", sumneko_opts, opts)
end

if server.name == "pyright" then
local pyright_opts = require("user.lsp.settings.pyright")
local pyright_opts = require("nn.lsp.settings.pyright")
opts = vim.tbl_deep_extend("force", pyright_opts, opts)
end

Expand Down
1 change: 0 additions & 1 deletion lua/nn/lsp/settings/pyright.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
return {
settings = {

python = {
analysis = {
typeCheckingMode = "off"
Expand Down
1 change: 0 additions & 1 deletion lua/nn/lsp/settings/sumneko_lua.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
return {
settings = {

Lua = {
diagnostics = {
globals = { "vim" },
Expand Down
6 changes: 4 additions & 2 deletions lua/nn/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ return packer.startup(function(use)
use "hrsh7th/cmp-cmdline"
use "saadparwaiz1/cmp_luasnip"
use "David-Kunz/cmp-npm"
use "hrsh7th/cmp-nvim-lsp"
use "hrsh7th/cmp-nvim-lua"

use "L3MON4D3/LuaSnip"
use "rafamadriz/friendly-snippets"
Expand All @@ -63,8 +65,8 @@ return packer.startup(function(use)
use "folke/tokyonight.nvim"

-- LSP
use "neovim/nvim-lspconfig" -- enable LSP
use "williamboman/nvim-lsp-installer" -- simple to use language server installer
use "neovim/nvim-lspconfig"
use "williamboman/nvim-lsp-installer"

-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
Expand Down
10 changes: 10 additions & 0 deletions plugin/packer_compiled.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ _G.packer_plugins = {
path = "/home/nn/.local/share/nvim/site/pack/packer/start/cmp-npm",
url = "https://github.com/David-Kunz/cmp-npm"
},
["cmp-nvim-lsp"] = {
loaded = true,
path = "/home/nn/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
url = "https://github.com/hrsh7th/cmp-nvim-lsp"
},
["cmp-nvim-lua"] = {
loaded = true,
path = "/home/nn/.local/share/nvim/site/pack/packer/start/cmp-nvim-lua",
url = "https://github.com/hrsh7th/cmp-nvim-lua"
},
["cmp-path"] = {
loaded = true,
path = "/home/nn/.local/share/nvim/site/pack/packer/start/cmp-path",
Expand Down

0 comments on commit 8637fca

Please sign in to comment.