Start to work with nvim because it is great

main
felixm 2023-06-13 21:38:23 -04:00
parent eccc6eae1f
commit 1dc6f38f0f
7 changed files with 266 additions and 1 deletions

17
config/nvim/init.lua Normal file
View File

@ -0,0 +1,17 @@
require('plugins')
require('mappings')
require('telescope_config')
-- Misc commands similar to my vimrc
vim.g.mapleader = ","
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.smarttab = true
vim.opt.relativenumber = true
vim.api.nvim_set_keymap('i', 'jk', '<Esc>', {noremap = true})
vim.cmd.colorscheme "catppuccin-frappe"
-- We don't need these two because we have oil
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

View File

@ -0,0 +1,43 @@
require('utils')
local wk = require("which-key")
wk.register({
f = {
name = "find",
f = { "<cmd>Telescope find_files<cr>", "File" },
g = { "<cmd>Telescope live_grep<cr>", "Grep" },
b = { "<cmd>Telescope buffers<cr>", "Buffers" },
h = { "<cmd>Telescope help_tags<cr>", "Help Tags" },
s = { "<cmd>Telescope colorscheme<cr>", "Colorscheme" },
c = { "<cmd>Telescope commands<cr>", "Commands" },
},
}, { prefix = "<leader>" })
wk.register({
b = {
name = "buffer",
q = { "<cmd>bdelete<cr>", "Quit" },
n = { "<cmd>bnext<cr>", "Next" },
p = { "<cmd>bprevious<cr>", "Prev" },
a = { "<cmd>unhide<cr>", "Show All" },
o = { "<cmd>Telescope buffers<cr>", "Open" },
e = { "<cmd>Oil<cr>", "Explorer" },
},
}, { prefix = "<leader>" })
wk.register({
w = {
name = "vim",
e = { "<cmd>edit ~/.config/nvim/init.lua<cr>", "Edit init.lua" },
r = { "<cmd>luafile ~/.config/nvim/init.lua<cr>|<cmd>source %<cr>", "Reload config" },
q = { "<cmd>q!<cr>", "Quit" },
a = { "<cmd>quitall!<cr>", "Quit All" },
w = { "<cmd>w<cr>", "Write" },
l = { "<cmd>SplitOrMove l<cr>", "Split or move right" },
h = { "<cmd>SplitOrMove h<cr>", "Split or move left" },
j = { "<cmd>SplitOrMove j<cr>", "Split or move down" },
k = { "<cmd>SplitOrMove k<cr>", "Split or move up" },
},
}, { prefix = "<leader>" })

View File

@ -0,0 +1,28 @@
return require('packer').startup(function(use)
use 'wbthomason/packer.nvim'
use { 'nvim-treesitter/nvim-treesitter' }
use { "catppuccin/nvim", name = "catppuccin" }
use 'nvim-tree/nvim-web-devicons'
use {
'nvim-telescope/telescope.nvim', branch = '0.1.x',
requires = { {'nvim-lua/plenary.nvim'} }
}
use {
"folke/which-key.nvim",
config = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end
}
use {
'stevearc/oil.nvim',
config = function() require('oil').setup() end
}
-- Local plugins can be included
-- use '~/projects/personal/hover.nvim'
end)

View File

@ -0,0 +1,11 @@
require('telescope').setup {
defaults = {
mappings = {
i = {
["<C-j>"] = require('telescope.actions').move_selection_next,
["<C-k>"] = require('telescope.actions').move_selection_previous,
},
},
},
}

21
config/nvim/lua/utils.lua Normal file
View File

@ -0,0 +1,21 @@
-- Declare the function in the _G table to make it globally available
_G.SplitOrMove = function(direction)
if vim.fn.winnr() ~= vim.fn.winnr(direction) then
vim.api.nvim_err_writeln('normal! <c-w>' .. direction)
vim.cmd(":wincmd " .. direction)
else
if direction == 'l' then
vim.cmd(":below vnew")
elseif direction == 'h' then
vim.cmd(":vnew")
elseif direction == 'j' then
vim.cmd(":below new")
elseif direction == 'k' then
vim.cmd(":new")
end
end
end
-- Create a command that you can reference from your which-key register
vim.cmd("command! -nargs=1 SplitOrMove lua _G.SplitOrMove(<q-args>)")

View File

@ -0,0 +1,144 @@
-- Automatically generated packer.nvim plugin loader code
if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
return
end
vim.api.nvim_command('packadd packer.nvim')
local no_errors, error_msg = pcall(function()
_G._packer = _G._packer or {}
_G._packer.inside_compile = true
local time
local profile_info
local should_profile = false
if should_profile then
local hrtime = vim.loop.hrtime
profile_info = {}
time = function(chunk, start)
if start then
profile_info[chunk] = hrtime()
else
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
end
end
else
time = function(chunk, start) end
end
local function save_profiles(threshold)
local sorted_times = {}
for chunk_name, time_taken in pairs(profile_info) do
sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
end
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
local results = {}
for i, elem in ipairs(sorted_times) do
if not threshold or threshold and elem[2] > threshold then
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
end
end
if threshold then
table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
end
_G._packer.profile_output = results
end
time([[Luarocks path setup]], true)
local package_path_str = "/home/felixm/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/felixm/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/felixm/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/felixm/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/felixm/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end
if not string.find(package.cpath, install_cpath_pattern, 1, true) then
package.cpath = package.cpath .. ';' .. install_cpath_pattern
end
time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
if not success then
vim.schedule(function()
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
end)
end
return result
end
time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
nvim = {
loaded = true,
path = "/home/felixm/.local/share/nvim/site/pack/packer/start/nvim",
url = "https://github.com/catppuccin/nvim"
},
["nvim-treesitter"] = {
loaded = true,
path = "/home/felixm/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
url = "https://github.com/nvim-treesitter/nvim-treesitter"
},
["nvim-web-devicons"] = {
loaded = true,
path = "/home/felixm/.local/share/nvim/site/pack/packer/start/nvim-web-devicons",
url = "https://github.com/nvim-tree/nvim-web-devicons"
},
["oil.nvim"] = {
config = { "\27LJ\2\n1\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\boil\frequire\0" },
loaded = true,
path = "/home/felixm/.local/share/nvim/site/pack/packer/start/oil.nvim",
url = "https://github.com/stevearc/oil.nvim"
},
["packer.nvim"] = {
loaded = true,
path = "/home/felixm/.local/share/nvim/site/pack/packer/start/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
["plenary.nvim"] = {
loaded = true,
path = "/home/felixm/.local/share/nvim/site/pack/packer/start/plenary.nvim",
url = "https://github.com/nvim-lua/plenary.nvim"
},
["telescope.nvim"] = {
loaded = true,
path = "/home/felixm/.local/share/nvim/site/pack/packer/start/telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim"
},
["which-key.nvim"] = {
config = { "\27LJ\2\nD\0\0\2\0\4\0\t6\0\0\0009\0\1\0+\1\2\0=\1\2\0006\0\0\0009\0\1\0)\1,\1=\1\3\0K\0\1\0\15timeoutlen\ftimeout\6o\bvim\0" },
loaded = true,
path = "/home/felixm/.local/share/nvim/site/pack/packer/start/which-key.nvim",
url = "https://github.com/folke/which-key.nvim"
}
}
time([[Defining packer_plugins]], false)
-- Config for: which-key.nvim
time([[Config for which-key.nvim]], true)
try_loadstring("\27LJ\2\nD\0\0\2\0\4\0\t6\0\0\0009\0\1\0+\1\2\0=\1\2\0006\0\0\0009\0\1\0)\1,\1=\1\3\0K\0\1\0\15timeoutlen\ftimeout\6o\bvim\0", "config", "which-key.nvim")
time([[Config for which-key.nvim]], false)
-- Config for: oil.nvim
time([[Config for oil.nvim]], true)
try_loadstring("\27LJ\2\n1\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\boil\frequire\0", "config", "oil.nvim")
time([[Config for oil.nvim]], false)
_G._packer.inside_compile = false
if _G._packer.needs_bufread == true then
vim.cmd("doautocmd BufRead")
end
_G._packer.needs_bufread = false
if should_profile then save_profiles() end
end)
if not no_errors then
error_msg = error_msg:gsub('"', '\\"')
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
end

View File

@ -1,9 +1,10 @@
#TARGET (relative to this file),LINK_NAME (relative to home)
config/kitty,.config/kitty
config/nvim,.config/nvim
config/picom,.config/picom
config/qtile,.config/qtile
config/qtile/xinitrc,.xinitrc
config/rofi,.config/rofi
config/picom,.config/picom
config/vim,.vim
config/vscode/settings.json,.config/Code - OSS/User/settings.json
config/zsh/ohmyzsh,.ohmyzsh

1 #TARGET (relative to this file) LINK_NAME (relative to home)
2 config/kitty .config/kitty
3 config/nvim .config/nvim
4 config/picom .config/picom
5 config/qtile .config/qtile
6 config/qtile/xinitrc .xinitrc
7 config/rofi .config/rofi
config/picom .config/picom
8 config/vim .vim
9 config/vscode/settings.json .config/Code - OSS/User/settings.json
10 config/zsh/ohmyzsh .ohmyzsh