neovim from scracth part 1
This commit is contained in:
parent
3480fa92fe
commit
21bcbd0bdc
8 changed files with 1051 additions and 805 deletions
7
.config/nvim/lua/config/autocmds.lua
Normal file
7
.config/nvim/lua/config/autocmds.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
desc = 'Highlight when yanking (copying) text',
|
||||
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
})
|
4
.config/nvim/lua/config/init.lua
Normal file
4
.config/nvim/lua/config/init.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
require("config.options")
|
||||
require("config.plugins")
|
||||
require("config.keymaps")
|
||||
require("config.autocmds")
|
42
.config/nvim/lua/config/keymaps.lua
Normal file
42
.config/nvim/lua/config/keymaps.lua
Normal file
|
@ -0,0 +1,42 @@
|
|||
-- General --
|
||||
|
||||
-- hjkl to ijkl remap
|
||||
vim.keymap.set({ 'n', 'v', 'o' }, 'j', 'h', { desc = 'hjkl to ijkl' })
|
||||
vim.keymap.set({ 'n', 'v', 'o' }, 'h', 'i', { desc = 'hjkl to ijkl' })
|
||||
vim.keymap.set({ 'n', 'v', 'o' }, 'i', 'k', { desc = 'hjkl to ijkl' })
|
||||
vim.keymap.set({ 'n', 'v', 'o' }, 'k', 'j', { desc = 'hjkl to ijkl' })
|
||||
|
||||
|
||||
-- indentation
|
||||
vim.keymap.set('n', '<Tab>', '>>', { desc = 'tab indent ' })
|
||||
vim.keymap.set('n', '<S-Tab>', '<<', { desc = 'S-tab unindent ' })
|
||||
vim.keymap.set({ 'v', 'o' }, '<Tab>', '>', { desc = 'tab indent ' })
|
||||
vim.keymap.set({ 'v', 'o' }, '<S-Tab>', '<', { desc = 'S-tab unindent ' })
|
||||
|
||||
|
||||
-- scrolling
|
||||
vim.keymap.set({ 'n', 'v', 'o' }, '<C-d>', '<C-d>zz', { desc = 'centered scroll' })
|
||||
vim.keymap.set({ 'n', 'v', 'o' }, '<C-u>', '<C-u>zz', { desc = 'centered scroll' })
|
||||
|
||||
-- start of line
|
||||
vim.keymap.set({ 'n', 'v', 'o' }, '#', '_', { desc = '# start of line' })
|
||||
|
||||
-- save
|
||||
vim.keymap.set('n', '<C-s>', ':w<CR>', { desc = 'ctrl-s save' })
|
||||
|
||||
-- Buffers --
|
||||
vim.keymap.set('n', '<leader>l', ':tabnext<CR>', { desc = 'next buffer' })
|
||||
vim.keymap.set('n', '<leader>j', ':tabprev<CR>', { desc = 'previous buffer' })
|
||||
|
||||
-- Telescope --
|
||||
local builtin = require('telescope.builtin')
|
||||
|
||||
vim.keymap.set('n', '<C-o>', builtin.find_files, { desc = 'Telescope find files' })
|
||||
|
||||
vim.keymap.set('n', '<leader>/', function()
|
||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
})
|
||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
43
.config/nvim/lua/config/options.lua
Normal file
43
.config/nvim/lua/config/options.lua
Normal file
|
@ -0,0 +1,43 @@
|
|||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
|
||||
vim.g.have_nerd_font = true
|
||||
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
vim.opt.mouse = 'a'
|
||||
|
||||
vim.opt.showmode = false
|
||||
|
||||
vim.schedule(function()
|
||||
vim.opt.clipboard = 'unnamedplus'
|
||||
end)
|
||||
|
||||
vim.opt.breakindent = true
|
||||
|
||||
-- save undo history
|
||||
vim.opt.undofile = true
|
||||
|
||||
-- Case insensitve search normally
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
|
||||
-- Configure how new splits should be opened
|
||||
vim.opt.splitright = true
|
||||
vim.opt.splitbelow = true
|
||||
|
||||
-- highlight current cursor line
|
||||
vim.opt.cursorline = true
|
||||
|
||||
-- Minimal number of screen lines to keep above and below the cursor.
|
||||
vim.opt.scrolloff = 10
|
||||
|
||||
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
|
||||
-- instead raise a dialog asking if you wish to save the current file(s)
|
||||
-- See `:help 'confirm'`
|
||||
vim.opt.confirm = true
|
||||
|
||||
vim.opt.signcolumn = yes
|
||||
|
||||
vim.o.showtabline = 2
|
166
.config/nvim/lua/config/plugins.lua
Normal file
166
.config/nvim/lua/config/plugins.lua
Normal file
|
@ -0,0 +1,166 @@
|
|||
-- [[ Install `lazy.nvim` plugin manager ]]
|
||||
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
|
||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
|
||||
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
|
||||
if vim.v.shell_error ~= 0 then
|
||||
error('Error cloning lazy.nvim:\n' .. out)
|
||||
end
|
||||
end ---@diagnostic disable-next-line: undefined-field
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require('lazy').setup({
|
||||
|
||||
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
|
||||
{
|
||||
'm4xshen/autoclose.nvim',
|
||||
config = function()
|
||||
require('autoclose').setup({})
|
||||
end
|
||||
},
|
||||
{
|
||||
'lewis6991/gitsigns.nvim',
|
||||
opts = {
|
||||
signs = {
|
||||
add = { text = '┃' },
|
||||
change = { text = '┃' },
|
||||
delete = { text = '_' },
|
||||
topdelete = { text = '‾' },
|
||||
changedelete = { text = '~' },
|
||||
untracked = { text = '┆' },
|
||||
},
|
||||
signs_staged = {
|
||||
add = { text = '┃' },
|
||||
change = { text = '┃' },
|
||||
delete = { text = '_' },
|
||||
topdelete = { text = '‾' },
|
||||
changedelete = { text = '~' },
|
||||
untracked = { text = '┆' },
|
||||
},
|
||||
signs_staged_enable = true,
|
||||
signcolumn = true
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
'nvim-telescope/telescope.nvim',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
|
||||
{
|
||||
'nvim-telescope/telescope-fzf-native.nvim',
|
||||
|
||||
build = 'make',
|
||||
|
||||
-- cond = function()
|
||||
-- return vim.fn.executable 'make' == 1
|
||||
-- end,
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
local actions = require('telescope.actions')
|
||||
local actions_state = require('telescope.actions.state')
|
||||
require('telescope').setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
["<esc>"] = actions.close,
|
||||
["<C-k>"] = actions.move_selection_next,
|
||||
["<C-i>"] = actions.move_selection_previous,
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
pickers = {
|
||||
find_files = {
|
||||
mappings = {
|
||||
i = {
|
||||
["<CR>"] = function(prompt_bufnr)
|
||||
local selection = actions_state.get_selected_entry()
|
||||
actions.close(prompt_bufnr)
|
||||
vim.cmd("tabnew " .. vim.fn.fnameescape(selection.path or selection.filename))
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
pcall(require('telescope').load_extension, 'fzf')
|
||||
end
|
||||
},
|
||||
|
||||
{
|
||||
'nanozuki/tabby.nvim',
|
||||
dependencies = 'nvim-tree/nvim-web-devicons',
|
||||
config = function()
|
||||
local theme = {
|
||||
-- this is carbonfox theme
|
||||
fill = 'TabLineFill',
|
||||
head = { fg = '#75beff', bg = '#1c1e26' },
|
||||
current_tab = { fg = '#1c1e26', bg = '#75beff' },
|
||||
tab = { fg = '#c5cdd9', bg = '#1c1e26' },
|
||||
win = { fg = '#1c1e26', bg = '#75beff' },
|
||||
tail = { fg = '#75beff', bg = '#1c1e26' },
|
||||
}
|
||||
|
||||
require('tabby.tabline').set(function(line)
|
||||
return {
|
||||
{
|
||||
{ ' ', hl = theme.head },
|
||||
line.sep('', theme.head, theme.fill),
|
||||
},
|
||||
line.tabs().foreach(function(tab)
|
||||
|
||||
local hl = tab.is_current() and theme.current_tab or theme.tab
|
||||
|
||||
-- remove count of wins in tab with [n+] included in tab.name()
|
||||
local name = tab.name()
|
||||
local index = string.find(name, "%[%d")
|
||||
local tab_name = index and string.sub(name, 1, index - 1) or name
|
||||
|
||||
-- indicate if any of buffers in tab have unsaved changes
|
||||
local modified = false
|
||||
local win_ids = require('tabby.module.api').get_tab_wins(tab.id)
|
||||
for _, win_id in ipairs(win_ids) do
|
||||
if pcall(vim.api.nvim_win_get_buf, win_id) then
|
||||
local bufid = vim.api.nvim_win_get_buf(win_id)
|
||||
if vim.api.nvim_buf_get_option(bufid, "modified") then
|
||||
modified = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
line.sep('', hl, theme.fill),
|
||||
tab_name,
|
||||
modified and '',
|
||||
line.sep('', hl, theme.fill),
|
||||
hl = hl,
|
||||
margin = ' ',
|
||||
}
|
||||
end),
|
||||
line.spacer(),
|
||||
{
|
||||
line.sep('', theme.tail, theme.fill),
|
||||
{ ' ', hl = theme.tail },
|
||||
},
|
||||
hl = theme.fill,
|
||||
}
|
||||
end)
|
||||
end
|
||||
},
|
||||
|
||||
{
|
||||
'nvim-lualine/lualine.nvim',
|
||||
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
opts = {
|
||||
options = {
|
||||
theme = 'ayu_mirage'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue