Update Neovim Lua config

This commit is contained in:
Gabriel Arazas 2021-10-08 13:38:47 +08:00
parent be245765f2
commit c4d4abc7a6

View File

@ -25,8 +25,11 @@ require("packer").startup(function()
-- Let the package manager manage itself. -- Let the package manager manage itself.
use { "wbthomason/packer.nvim", opt = true } use { "wbthomason/packer.nvim", opt = true }
-- THEMES! -- THEMES!
use { "chriskempson/base16-vim" } use { "chriskempson/base16-vim" }
-- Custom color themes!
use { "rktjmp/lush.nvim" }
-- EditorConfig plugin -- EditorConfig plugin
use { "editorconfig/editorconfig-vim" } use { "editorconfig/editorconfig-vim" }
@ -39,10 +42,18 @@ require("packer").startup(function()
end end
} }
-- Start flavours
-- Our custom theme
use { "~/.config/nvim/lua/lush_theme/fds-theme.lua" }
-- A snippets engine. -- A snippets engine.
-- One of the must-haves for me. -- One of the must-haves for me.
use { use {
"sirver/ultisnips", "sirver/ultisnips",
config = function()
vim.g.UltiSnipsEditSplit = "context"
vim.g.UltiSnipsSnippetDirectories = {vim.env.HOME .. "/.config/nvim/own-snippets", ".snippets"}
end,
-- Contains various snippets for UltiSnips. -- Contains various snippets for UltiSnips.
requires = "honza/vim-snippets" requires = "honza/vim-snippets"
@ -75,14 +86,14 @@ require("packer").startup(function()
end end
local check_back_space = function() local check_back_space = function()
local col = vim.fn.col(".") - 1 local col = fn.col(".") - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") ~= nil return col == 0 or fn.getline("."):sub(col, col):match("%s") ~= nil
end end
cmp.setup({ cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
vim.fn["UltiSnips#Anon"](args.body) fn["UltiSnips#Anon"](args.body)
end, end,
}, },
@ -96,14 +107,14 @@ require("packer").startup(function()
mapping = { mapping = {
["<C-Space>"] = cmp.mapping(function(fallback) ["<C-Space>"] = cmp.mapping(function(fallback)
if vim.fn.pumvisible() == 1 then if fn.pumvisible() == 1 then
if vim.fn["UltiSnips#CanExpandSnippet"]() == 1 then if fn["UltiSnips#CanExpandSnippet"]() == 1 then
return vim.fn.feedkeys(t("<C-R>=UltiSnips#ExpandSnippet()<CR>")) return fn.feedkeys(t("<C-R>=UltiSnips#ExpandSnippet()<CR>"))
end end
vim.fn.feedkeys(t("<C-n>"), "n") fn.feedkeys(t("<C-n>"), "n")
elseif check_back_space() then elseif check_back_space() then
vim.fn.feedkeys(t("<cr>"), "n") fn.feedkeys(t("<cr>"), "n")
else else
fallback() fallback()
end end
@ -113,14 +124,14 @@ require("packer").startup(function()
}), }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if vim.fn.complete_info()["selected"] == -1 and vim.fn["UltiSnips#CanExpandSnippet"]() == 1 then if fn.complete_info()["selected"] == -1 and fn["UltiSnips#CanExpandSnippet"]() == 1 then
vim.fn.feedkeys(t("<C-R>=UltiSnips#ExpandSnippet()<CR>")) fn.feedkeys(t("<C-R>=UltiSnips#ExpandSnippet()<CR>"))
elseif vim.fn["UltiSnips#CanJumpForwards"]() == 1 then elseif fn["UltiSnips#CanJumpForwards"]() == 1 then
vim.fn.feedkeys(t("<ESC>:call UltiSnips#JumpForwards()<CR>")) fn.feedkeys(t("<ESC>:call UltiSnips#JumpForwards()<CR>"))
elseif vim.fn.pumvisible() == 1 then elseif fn.pumvisible() == 1 then
vim.fn.feedkeys(t("<C-n>"), "n") fn.feedkeys(t("<C-n>"), "n")
elseif check_back_space() then elseif check_back_space() then
vim.fn.feedkeys(t("<tab>"), "n") fn.feedkeys(t("<tab>"), "n")
else else
fallback() fallback()
end end
@ -130,10 +141,10 @@ require("packer").startup(function()
}), }),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if vim.fn["UltiSnips#CanJumpBackwards"]() == 1 then if fn["UltiSnips#CanJumpBackwards"]() == 1 then
return vim.fn.feedkeys(t("<C-R>=UltiSnips#JumpBackwards()<CR>")) return fn.feedkeys(t("<C-R>=UltiSnips#JumpBackwards()<CR>"))
elseif vim.fn.pumvisible() == 1 then elseif fn.pumvisible() == 1 then
vim.fn.feedkeys(t("<C-p>"), "n") fn.feedkeys(t("<C-p>"), "n")
else else
fallback() fallback()
end end
@ -202,16 +213,14 @@ require("packer").startup(function()
end) end)
-- g['UltiSnipsExpandTrigger'] = "<c-j>" -- g['UltiSnipsExpandTrigger'] = "<c-j>"
g['UltiSnipsEditSplit'] = "context"
g['UltiSnipsSnippetDirectories'] = {vim.env.HOME .. "/.config/nvim/own-snippets", ".snippets"}
local t = function(str) local t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true) return vim.api.nvim_replace_termcodes(str, true, true, true)
end end
local check_back_space = function() local check_back_space = function()
local col = vim.fn.col('.') - 1 local col = fn.col('.') - 1
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then if col == 0 or fn.getline('.'):sub(col, col):match('%s') then
return true return true
else else
return false return false
@ -241,6 +250,7 @@ cmd "highlight clear SpellCap"
cmd "highlight clear SpellRare" cmd "highlight clear SpellRare"
cmd "highlight CursorLineNr ctermfg=cyan" cmd "highlight CursorLineNr ctermfg=cyan"
cmd "highlight Visual term=reverse cterm=reverse" cmd "highlight Visual term=reverse cterm=reverse"
cmd "colorscheme fds-theme"
-- Keybindings -- Keybindings
map('i', 'jk', '<Esc>', {}) map('i', 'jk', '<Esc>', {})