feat: some stuff

This commit is contained in:
2021-12-18 14:41:37 +01:00
parent a6721b9de2
commit 6d0af46768
7 changed files with 240 additions and 241 deletions

View File

@ -1,14 +1,10 @@
-- luasnip setup
local cmd = vim.cmd;
local luasnip = require "luasnip"
local lspkind = require "lspkind"
local cmp = require "cmp"
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
cmp.setup {
formatting = {
format = lspkind.cmp_format({with_text = true, menu = ({
@ -32,34 +28,27 @@ cmp.setup {
},
mapping = {
['<C-Leader>'] = cmp.mapping.complete(),
["<Tab>"] = cmp.mapping(function(fallback)
["<Tab>"] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
end,
["<S-Tab>"] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end,
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
},
sources = {
{name = "nvim-lua"},
{name = "nvim_lsp"},
{name = "luasnip"},
{name = "path"},

View File

@ -1,8 +1,8 @@
local cmd = vim.cmd;
local cmd = vim.cmd
cmd [[
augroup auto_format
au!
au BufWritePre * FormatSync
au BufWritePre * Neoformat
augroup END
]]

View File

@ -34,13 +34,15 @@ map("n", "Y", "yy", options)
map("n", "<Leader>k", "{",options)
map("n", "<Leader>j", "}",options)
-- Move lines vscode style
map("n", "<A-j>", "<cmd>move +1<CR>", options)
map("n", "<A-k>", "<cmd>move -2<CR>", options)
map("i", "<A-j>", "<cmd>move +1<CR>", options)
map("i", "<A-k>", "<cmd>move -2<CR>", options)
map("v", "<A-j>", ":m '>+1<CR>gv=gv", options)
map("v", "<A-k>", ":m '<-2<CR>gv=gv", options)
map("n", "<A-S-k>", "YP", options);
map("n", "<A-S-j>", "Yp", options);
-- Faster git merge
map("n", "<Leader>gd", ":Gvdiffsplit!<CR>", options)

View File

@ -13,7 +13,8 @@ return require("packer").startup(function()
use 'lervag/vimtex'
-- Theming Section
use 'folke/tokyonight.nvim'
-- use 'folke/tokyonight.nvim'
use 'EdenEast/nightfox.nvim'
use "xiyaowong/nvim-transparent"
-- Layout Plugins
@ -47,20 +48,16 @@ return require("packer").startup(function()
"folke/trouble.nvim",
requires = "kyazdani42/nvim-web-devicons",
config = function()
require("trouble").setup {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
require("trouble").setup()
end
}
-- Syntax / Autocomplete
use "terminalnode/sway-vim-syntax"
use "neovim/nvim-lspconfig"
use "github/copilot.vim"
-- use "github/copilot.vim"
use "hrsh7th/nvim-cmp"
use "hrsh7th/cmp-nvim-lsp"
use "hrsh7th/cmp-nvim-lua"
use "hrsh7th/cmp-path"
use "hrsh7th/cmp-calc"
use "hrsh7th/cmp-buffer"
@ -86,7 +83,7 @@ return require("packer").startup(function()
use "ellisonleao/glow.nvim"
-- Autoformat
--use "sbdchd/neoformat"
use "sbdchd/neoformat"
-- use "lukas-reineke/format.nvim"
-- General Popup Window

View File

@ -2,40 +2,42 @@ local M = {}
local cmd = vim.cmd
function M.create_augroup(autocmds, name)
cmd('augroup ' .. name)
cmd('autocmd!')
for _, autocmd in ipairs(autocmds) do
cmd('autocmd ' .. table.concat(autocmd, ' '))
end
cmd('augroup END')
cmd("augroup " .. name)
cmd("autocmd!")
for _, autocmd in ipairs(autocmds) do
cmd("autocmd " .. table.concat(autocmd, " "))
end
cmd("augroup END")
end
function M.ReloadConfig()
for name,_ in pairs(package.loaded) do
if name:match('^cnull') then
package.loaded[name] = nil
end
end
for name, _ in pairs(package.loaded) do
if name:match("^cnull") then
package.loaded[name] = nil
end
end
dofile(vim.env.MYVIMRC)
dofile(vim.env.MYVIMRC)
end
local function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
if type(o) == "table" then
local s = "{ "
for k, v in pairs(o) do
if type(k) ~= "number" then
k = '"' .. k .. '"'
end
s = s .. "[" .. k .. "] = " .. dump(v) .. ","
end
return s .. "} "
else
return tostring(o)
end
end
function M.has_plugin(pluginName)
local status = pcall(require, pluginName);
return status
local status = pcall(require, pluginName)
return status
end
return M