summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/custom
diff options
context:
space:
mode:
authorKyren223 <ulmliad223@gmail.com>2024-07-08 13:42:25 +0300
committerKyren223 <ulmliad223@gmail.com>2024-07-08 13:42:25 +0300
commit5bc29f77a48b8e46513c982362a55884e7f65238 (patch)
tree111426ddee2e7a30cd974b29bc83f50610f4ced5 /.config/nvim/lua/custom
parentb491f9e3a73367dfd54ca8f8bc74008332c80f34 (diff)
Neovim: worked more on completions, and changed a few other things in keymaps and options
Diffstat (limited to '.config/nvim/lua/custom')
-rw-r--r--.config/nvim/lua/custom/completion.lua44
-rw-r--r--.config/nvim/lua/custom/lsp.lua24
2 files changed, 21 insertions, 47 deletions
diff --git a/.config/nvim/lua/custom/completion.lua b/.config/nvim/lua/custom/completion.lua
index 50df64b..80c9531 100644
--- a/.config/nvim/lua/custom/completion.lua
+++ b/.config/nvim/lua/custom/completion.lua
@@ -7,7 +7,7 @@ cmp.event:on('confirm_done', require('nvim-autopairs.completion.cmp').on_confirm
-- Helper functions
local function tab(is_forward)
- cmp.mapping(function(fallback)
+ return cmp.mapping(function(fallback)
local jump_amount = is_forward and 1 or -1
if cmp.visible() then
local behaviour = cmp.SelectBehavior.Select
@@ -21,8 +21,6 @@ local function tab(is_forward)
end, { 'i', 's' })
end
-local function enter() end
-
local function is_enabled()
local context = require('cmp.config.context')
@@ -43,6 +41,7 @@ cmp.setup({
{ name = 'lazydev', group_index = 0 }, -- for lazydev.nvim
{ name = 'path' }, -- for filesystem
}),
+
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
@@ -54,46 +53,19 @@ cmp.setup({
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
- -- TODO: Make good keybindings
['<Tab>'] = tab(true),
['<S-Tab>'] = tab(false),
- ['<CR>'] = cmp.mapping(function(fallback)
- if cmp.visible() then
- if luasnip.expandable() then
- luasnip.expand()
- else
- cmp.confirm({ select = true })
- end
- else
- fallback()
- end
- end),
-
+ ['<C-Space>'] = cmp.mapping.complete(), -- invoke completion
+ ['<CR>'] = cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Insert }),
+ ['<C-u>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-d>'] = cmp.mapping.scroll_docs(4),
+ ['<C-m>'] = cmp.mapping.abort(),
-- NOTE: Select makes it so it doesn't put the text in the buffer (like Insert or defualt does)
-- Ex: typing "p" and then select "private" will not write "private" in your buffer, but keep it "p"
-- Only after accepting the suggestion then it'll become "private"
['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
-
- ['<CR>'] = cmp.mapping(
- cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Insert }),
- { 'i', 'c' }
- ),
-
- ['<C-Space>'] = cmp.mapping.complete(), -- invoke completion
- ['<C-u>'] = cmp.mapping.scroll_docs(-4),
- ['<C-d>'] = cmp.mapping.scroll_docs(4),
-
- -- ['<C-k>'] = cmp.mapping.abort(),
- -- ['<CR>'] = cmp.mapping.confirm({ select = true }),
- -- ['<C-y>'] = cmp.mapping(
- -- cmp.mapping.confirm({
- -- behavior = cmp.ConfirmBehavior.Insert,
- -- select = true,
- -- }),
- -- { 'i', 'c' }
- -- ),
}),
})
-print('Sourced lsp.lua')
+print('Sourced completion.lua')
diff --git a/.config/nvim/lua/custom/lsp.lua b/.config/nvim/lua/custom/lsp.lua
index 1238001..d534e22 100644
--- a/.config/nvim/lua/custom/lsp.lua
+++ b/.config/nvim/lua/custom/lsp.lua
@@ -1,18 +1,18 @@
-- NOTE: A list of language servers (and potentially their config)
-- Accepts either true to enable, false to disable or a table with settings
local servers = {
- lua_ls = true, -- lua
- clangd = true, -- C/C++
- gradle_ls = true, -- java package manager
- jdtls = true, -- java eclipse lsp
+ lua_ls = true, -- lua
+ clangd = true, -- C/C++
+ gradle_ls = true, -- java package manager
+ jdtls = true, -- java eclipse lsp
kotlin_language_server = true, -- kotlin
- pyright = true, -- python
- rust_analyzer = true, -- rust
- bashls = true, -- bash
- taplo = true, -- toml
- lemminx = true, -- xml
- yamlls = true, -- yaml
- jsonls = true, -- json
+ pyright = true, -- python
+ rust_analyzer = true, -- rust
+ bashls = true, -- bash
+ taplo = true, -- toml
+ lemminx = true, -- xml
+ yamlls = true, -- yaml
+ jsonls = true, -- json
}
-- NOTE: Not language servers but still make sure mason installs them
@@ -97,3 +97,5 @@ vim.api.nvim_create_autocmd('LspAttach', {
--
-- require('lsp_lines').setup()
-- vim.diagnostic.config({ virtual_text = false })
+
+print('Sourced lsp.lua')