Skip to content

Commit

Permalink
transform nvim config to lua
Browse files Browse the repository at this point in the history
  • Loading branch information
LucienMorey committed Sep 7, 2024
1 parent ec25513 commit 97f192c
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
**__pycache__/

**/lazy-lock.json
4 changes: 4 additions & 0 deletions nvim/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require("config.lazy")

require("config.mappings")
require("config.options")
40 changes: 0 additions & 40 deletions nvim/init.vim

This file was deleted.

25 changes: 25 additions & 0 deletions nvim/lua/config/lazy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- Bootstrap lazy.nvim
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
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)

-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
-- vim.g.mapleader = " "
-- vim.g.maplocalleader = "\\"

-- Setup lazy.nvim
require("lazy").setup("plugins")
20 changes: 20 additions & 0 deletions nvim/lua/config/mappings.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
local function map(mode, lhs, rhs, opts)
local options = { noremap=true, silent=true }
if opts then
options = vim.tbl_extend('force', options, opts)
end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end

-- Do not remap leader in this file if that is desired. Do so in the lazy config before plugins are loaded

-- Disable arrow keys
map('', '<up>', '<nop>')
map('', '<down>', '<nop>')
map('', '<left>', '<nop>')
map('', '<right>', '<nop>')

-- Map Esc to jk
map('i', 'jk', '<Esc>')

map("n", ';', ":")
11 changes: 11 additions & 0 deletions nvim/lua/config/options.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- enable line number and relative line number
vim.opt.number = true
vim.opt.relativenumber = true

-- width of a tab
vim.opt.shiftwidth = 2
vim.opt.tabstop = 2
vim.opt.softtabstop = 2

-- use number of spaces to insert a <Tab>
vim.opt.expandtab = true
32 changes: 32 additions & 0 deletions nvim/lua/plugins/colourscheme.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
return {
{
'marko-cerovac/material.nvim',
priority = 1000,
config = function()
local material = require 'material'

vim.g.material_style = 'oceanic'

material.setup {
-- vibrant_syntax = true,
contrast = {
cursor_line = true,
},
disable = {
eob_lines = true,
-- borders = true,
},
styles = {
comments = { italic = true },
functions = { italic = true },
},
plugins = {
'telescope',
},
}

-- enable the colorscheme
vim.cmd 'colorscheme material'
end
},
}
24 changes: 24 additions & 0 deletions nvim/lua/plugins/treesitter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
return {
{
'nvim-treesitter/nvim-treesitter',
dependencies = { 'nvim-treesitter/nvim-treesitter-textobjects' },
build = function()
require('nvim-treesitter.install').update({ with_sync = true })
end,
event = {
'BufReadPost',
'BufNewFile',
},
config = function()
require 'nvim-treesitter.configs'.setup {
ensure_installed = { 'arduino', 'bash', 'bitbake', 'c', 'cmake', 'cpp', 'devicetree', 'git_config', 'git_rebase', 'gitattributes', 'gitcommit', 'gitignore', 'glsl', 'json' , 'json5', 'lua', 'markdown', 'python', 'ruby', 'rst', 'tmux', 'vim', 'yaml' },
sync_install = false,
highlight = { enable = true },
incremental_selection = { enable = false },
indent = { enable = true },
}

vim.cmd 'set foldexpr=nvim_treesitter#foldexpr()'
end,
}
}

0 comments on commit 97f192c

Please sign in to comment.