summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackson Taylor <jtaylor@classicalconversations.com>2023-06-12 00:54:25 -0400
committerJackson Taylor <jtaylor@classicalconversations.com>2023-06-12 00:54:25 -0400
commit90d91e2a276c5fe1e33730d3b5ce2a9a4d8ee684 (patch)
treed1149b6bffb855935b4b73d0ec36c1be5c6191b4
parentc26d15c3a5abd2ec51f777b0337d632e850d087d (diff)
Document LSP better
I finally understand more about LSP and think I have a good setup now. The biggest changes are the order of the autocomplete stuff. This helps with the lag issues(I hope). I also ensure that a few language servers are installed, because those are the languages I use most. I will probably add more soon (SQL).
-rw-r--r--after/plugin/lsp.lua38
-rw-r--r--lua/jacksontaylorxyz/packer.lua8
2 files changed, 27 insertions, 19 deletions
diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua
index 0a2c4ff..f58bfbd 100644
--- a/after/plugin/lsp.lua
+++ b/after/plugin/lsp.lua
@@ -4,40 +4,48 @@ lsp.preset("recommended")
lsp.ensure_installed({
'tsserver',
- 'eslint'
+ 'eslint',
+ 'pylsp',
+ 'gopls',
+ 'lua_ls',
})
-- Fix Undefined global 'vim'
lsp.configure('lua-language-server', {
- settings = {
- Lua = {
- diagnostics = {
- globals = { 'vim' }
- }
- }
+ settings = {
+ Lua = {
+ diagnostics = {
+ globals = { 'vim' }
+ }
}
+ }
})
-print('in lsp.lua')
--- will exclude all javascript snippets
--- require("luasnip.loaders.from_vscode").load {
--- exclude = { "markdown" },
--- }
-
+-- Autocomplettion engine setup
+-- This is the drop downs that come up
local cmp = require('cmp')
local cmp_select = {behavior = cmp.SelectBehavior.Select}
+-- These are the mappings to use to navigate the dropdown menu. I usually use <CR> (Enter) the most, or the arrow keys, but these are nice.
local cmp_mappings = lsp.defaults.cmp_mappings({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
})
-
cmp_mappings['<Tab>'] = nil
cmp_mappings['<S-Tab>'] = nil
+-- This tells the Autocomplettion engine where to get its autocompletes from
+-- and the mappings to use.
lsp.setup_nvim_cmp({
- mapping = cmp_mappings
+ mapping = cmp_mappings,
+ -- NOTE: Priority matters for this. I put buffer on top because I was getting a lot of lag if I happened to type a snippet.
+ -- I feel like what I'm writing is, more often than not, something I've already written so I don't mind scrolling down in the list if I have to make a function or actually use one of the snippets.
+ sources = {
+ {name = 'buffer'}, -- words found in your buffer (cmp-buffer)
+ {name = 'nvim_lsp'}, -- everything the language server finds (neovim/nvim-lspconfig)
+ {name = 'luasnip'}, -- custom/popular snippets for languages (L3MON4D3/LuaSnip and rafamadriz/friendly-snippets)
+ }
})
lsp.set_preferences({
diff --git a/lua/jacksontaylorxyz/packer.lua b/lua/jacksontaylorxyz/packer.lua
index d41f6eb..b5d2267 100644
--- a/lua/jacksontaylorxyz/packer.lua
+++ b/lua/jacksontaylorxyz/packer.lua
@@ -102,16 +102,16 @@ return require('packer').startup(function(use)
{'williamboman/mason-lspconfig.nvim'}, -- Optional -- Manages the connection between what's installed with mason and the lsp config
-- Autocompletion
- {'hrsh7th/nvim-cmp'}, -- Required
- {'hrsh7th/cmp-nvim-lsp'}, -- Required
+ {'hrsh7th/nvim-cmp'}, -- Required -- Completion engine, gets what to complete from different sources (LSP for one)
+ {'hrsh7th/cmp-nvim-lsp'}, -- Required -- Converts
{'hrsh7th/cmp-buffer'}, -- Optional
{'hrsh7th/cmp-path'}, -- Optional
{'saadparwaiz1/cmp_luasnip'}, -- Optional
{'hrsh7th/cmp-nvim-lua'}, -- Optional
-- Snippets
- {'L3MON4D3/LuaSnip'}, -- Required
- {'rafamadriz/friendly-snippets'}, -- Optional
+ {'L3MON4D3/LuaSnip'}, -- Required -- Snippet engine
+ {'rafamadriz/friendly-snippets'}, -- Optional -- The actual snippets
}
}
-- use {'fatih/vim-go', run = ':GoInstallBinaries GoUpdateBinaries' } -- Nice Golang plugin