Upload local files

This commit is contained in:
2022-11-01 17:34:57 +01:00
commit bc13bdd6ca
6 changed files with 437 additions and 0 deletions

10
lua/callbacks.lua Normal file
View File

@ -0,0 +1,10 @@
goyo_unhide = true
function goyo_toggle()
if goyo_unhide == true then
require('lualine').hide({unhide=false})
goyo_unhide = false
else
require('lualine').hide({unhide=true})
goyo_unhide = true
end
end

127
lua/completion.lua Normal file
View File

@ -0,0 +1,127 @@
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
local snip_status_ok, luasnip = pcall(require, "luasnip")
if not snip_status_ok then
return
end
require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function()
local col = vim.fn.col "." - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
end
--   פּ ﯟ   some other good icons
local kind_icons = {
Text = "",
Method = "m",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
}
-- find more here: https://www.nerdfonts.com/cheat-sheet
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = {
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
["<C-e>"] = cmp.mapping {
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
},
-- Accept currently selected item. If none selected, `select` first item.
-- Set `select` to `false` to only confirm explicitly selected items.
["<CR>"] = cmp.mapping.confirm { select = true },
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end, {
"i",
"s",
}),
["<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",
}),
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- Kind icons
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
vim_item.menu = ({
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
})[entry.source.name]
return vim_item
end,
},
sources = {
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
-- documentation = {
-- border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
-- },
-- experimental = {
-- ghost_text = false,
-- native_menu = false,
-- },
}

41
lua/config.lua Normal file
View File

@ -0,0 +1,41 @@
vim.o.mouse = 'a'
vim.o.encoding = 'UTF-8'
vim.o.fileencoding = 'UTF-8'
vim.o.number = true
vim.o.relativenumber = true
vim.o.showcmd = true
vim.o.syntax = true
vim.o.ignorecase = true
vim.o.smartcase = true
vim.o.cursorline = true
-- bold line number at cursor
vim.cmd [[ highlight CursorLineNr cterm=bold ]]
vim.o.linebreak = true
-- special characters
vim.o.list = true
vim.o.listchars = 'tab:→ ,eol:↲,nbsp:␣,trail:•,extends:⟩,precedes:⟨'
vim.o.tabstop = 4
vim.o.shiftwidth = 4
vim.o.expandtab = false
vim.o.smartindent = true
-- spellcheck (enable with `set spell`)
vim.o.spelllang = 'cs,en_gb'
vim.cmd [[ hi SpellBad cterm=bold ctermbg=red ctermfg=white ]]
-- cursor padding from top and bottom
vim.o.scrolloff = 5
-- better navigation in split windows
vim.keymap.set('n', '<C-h>', '<C-w>h')
vim.keymap.set('n', '<C-j>', '<C-w>j')
vim.keymap.set('n', '<C-k>', '<C-w>k')
vim.keymap.set('n', '<C-h>', '<C-w>l')
-- colorscheme
vim.cmd [[ color base16-default-dark ]]

55
lua/plugins.lua Normal file
View File

@ -0,0 +1,55 @@
return require('packer').startup(function()
-- automatic rebuild on plugins.lua change
vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]])
use 'wbthomason/packer.nvim'
use 'RRethy/nvim-base16'
use 'tpope/vim-commentary'
use {
'nvim-lualine/lualine.nvim',
requires = { 'kyazdani42/nvim-web-devicons', opt = true },
config = function()
require('lualine').setup()
vim.o.showmode = false
end
}
use {
'lewis6991/gitsigns.nvim',
config = function()
require('gitsigns').setup()
end
}
use {
'junegunn/goyo.vim',
config = function()
vim.keymap.set('n', '<leader>f', ':lua goyo_toggle()<cr>:Goyo<cr>')
end
}
-- completion
use 'hrsh7th/nvim-cmp'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-cmdline'
use 'saadparwaiz1/cmp_luasnip'
-- snippets
use 'L3MON4D3/LuaSnip'
use 'rafamadriz/friendly-snippets'
-- LSP
use 'neovim/nvim-lspconfig'
use {
'williamboman/mason.nvim',
config = function()
require('mason').setup()
end
}
use 'williamboman/mason-lspconfig.nvim'
end)