aboutsummaryrefslogtreecommitdiff
path: root/lua/plugins/cmp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/plugins/cmp.lua')
-rw-r--r--lua/plugins/cmp.lua157
1 files changed, 157 insertions, 0 deletions
diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua
new file mode 100644
index 0000000..1eb9646
--- /dev/null
+++ b/lua/plugins/cmp.lua
@@ -0,0 +1,157 @@
1return {
2 {
3 'hrsh7th/nvim-cmp',
4 dependencies = {
5 'nvim-lua/popup.nvim',
6 'nvim-lua/plenary.nvim',
7 'saadparwaiz1/cmp_luasnip',
8 "hrsh7th/cmp-emoji",
9 'hrsh7th/cmp-nvim-lsp',
10 'hrsh7th/cmp-buffer',
11 'hrsh7th/cmp-path',
12 'hrsh7th/vim-vsnip',
13 'octaltree/cmp-look',
14 'folke/trouble.nvim',
15 {
16 'L3MON4D3/LuaSnip',
17 config = function()
18 vim.keymap.set(
19 {"i", "s"},
20 "<leader><Tab>",
21 function() require('luasnip').jump(1) end,
22 {silent = true}
23 )
24 vim.keymap.set(
25 {"i", "s"},
26 "<leader><S-Tab>",
27 function() require('luasnip').jump(-1) end,
28 {silent = true}
29 )
30 end,
31 },
32 },
33
34 config = function()
35 require('trouble').setup()
36
37 local cmp = require'cmp'
38 cmp.setup({
39 snippet = {
40 -- REQUIRED - you must specify a snippet engine
41 expand = function(args)
42 require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
43 -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
44 end,
45 },
46 window = {
47 completion = cmp.config.window.bordered(),
48 documentation = cmp.config.window.bordered(),
49 },
50 mapping = cmp.mapping.preset.insert({
51 ['<C-b>'] = cmp.mapping.scroll_docs(-4),
52 ['<C-f>'] = cmp.mapping.scroll_docs(4),
53 ['<C-Space>'] = cmp.mapping.complete(),
54 ['<C-e>'] = cmp.mapping.abort(),
55 ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
56 }),
57 sources = cmp.config.sources({
58 { name = 'nvim_lsp' },
59 { name = 'luasnip' }, -- For luasnip users.
60 }, {
61 { name = 'buffer' },
62 })
63 })
64 end
65 },
66 {
67 'neovim/nvim-lspconfig',
68 dependencies = {
69 { "folke/neodev.nvim" }
70 },
71 config = function()
72 -- Set up lspconfig.
73 local keymap = vim.keymap
74 local on_attach = function(client, bufnr)
75 local opts = { noremap = true, silent = true, buffer = bufnr }
76 keymap.set("n", "gf", "<cmd>Lspsaga lsp_finder<CR>", opts) -- show definition, references
77 keymap.set("n", "gD", "<Cmd>Lspsaga goto_definition<CR>", opts) -- got to declaration
78 keymap.set("n", "gd", "<cmd>Lspsaga peek_definition<CR>", opts) -- see definition and make edits in window
79 keymap.set("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) -- go to implementation
80 keymap.set("n", "<leader>ca", "<cmd>Lspsaga code_action<CR>", opts) -- see available code actions
81 keymap.set("n", "<leader>rn", "<cmd>Lspsaga rename<CR>", opts) -- smart rename
82 keymap.set("n", "<leader>D", "<cmd>Lspsaga show_line_diagnostics<CR>", opts) -- show diagnostics for line
83 keymap.set("n", "<leader>d", "<cmd>Lspsaga show_cursor_diagnostics<CR>", opts) -- show diagnostics for cursor
84 keymap.set("n", "[d", "<cmd>Lspsaga diagnostic_jump_prev<CR>", opts) -- jump to previous diagnostic in buffer
85 keymap.set("n", "]d", "<cmd>Lspsaga diagnostic_jump_next<CR>", opts) -- jump to next diagnostic in buffer
86 keymap.set("n", "K", "<cmd>Lspsaga hover_doc<CR>", opts) -- show documentation for what is under cursor
87 keymap.set("n", "<leader>o", "<cmd>LSoutlineToggle<CR>", opts) -- see outline on right hand side
88 keymap.set("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
89 vim.keymap.set("n", "<C-n>", ":cnext<CR>")
90 vim.keymap.set("n", "<C-p>", ":cprev<CR>")
91 end
92
93 local capabilities = require("cmp_nvim_lsp").default_capabilities()
94
95 -- # Language Servers
96 -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
97 for _,server in ipairs({
98 'bitbake_language_server',
99 "clangd", -- C/C++ | clang
100 "ts_ls", -- javascript | typescript-language-server
101 "lua_ls", -- lua (but not init.lua entirely, hence why neodev)
102 "jdtls",
103 "html",
104 "cssls", -- ccs | vscode-css-languageserver
105 "rust_analyzer", -- rust | rust-analyzer
106 "eslint", -- javascript | eslint
107 'vimls', -- vimscript | vim-language-server
108 'html', -- html
109 'jsonls', -- jsonls
110 "pyright", -- python
111 "bashls", -- bash | bash-language-server
112 "gopls",
113 "emmet_ls",
114 "marksman"}) do
115 require("lspconfig")[server].setup({
116 capabilities = capabilities,
117 on_attach = on_attach
118 })
119 end
120
121 -- # specialized config for some LSPs which have non-ideal defaults
122 --
123 -- require('lspconfig')['java_language_server'].setup{ cmd = { "/usr/share/java/java-language-server/lang_server_linux.sh" }, root_dir = function () return vim.fn.getcwd() end }
124 -- configure html server
125 require('lspconfig')["html"].setup({
126 init_options = {
127 configurationSection = { "html", "css", "javascript" },
128 embeddedLanguages = {
129 css = true,
130 javascript = true,
131 },
132 provideFormatter = true,
133 },
134 })
135 require('lspconfig')['pylsp'].setup{
136 settings = {
137 pylsp = {
138 plugins = {
139 pycodestyle = {
140 ignore = {'W391'},
141 maxLineLength = 100
142 }
143 }
144 }
145 }
146 }
147 require("lspconfig").clangd.setup {
148 on_attach = on_attach,
149 capabilities = capabilities,
150 cmd = {
151 "clangd",
152 "--offset-encoding=utf-16",
153 },
154 }
155 end
156 }
157}
..