Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-organize nvim lua init #32

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ end_of_line = lf
[*.{cmd,ps1,csv,doskey}]
end_of_line = crlf

[*.{sh,yml}]
[*.{lua,sh,yml}]
indent_size = 2

4 changes: 4 additions & 0 deletions nvim/.luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"diagnostics.globals": [
]
}
14 changes: 4 additions & 10 deletions nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@
-- neovim standard paths:
-- https://neovim.io/doc/user/starting.html#standard-path

local cmd = vim.cmd

require('dotfiles.core.options')
require('dotfiles.core.keymaps')
require('dotfiles.lazy-nvim')

cmd[[ colorscheme tokyonight]]
-- cmd[[ colorscheme nord]]

require('dotfiles.plugin-config')
require('options')
require('keymaps')
require('lazy-nvim')

vim.cmd[[ colorscheme tokyonight]]
22 changes: 12 additions & 10 deletions nvim/lazy-lock.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{
"catppuccin": { "branch": "main", "commit": "5e36ca599f4aa41bdd87fbf2c5aae4397ac55074" },
"gitsigns.nvim": { "branch": "main", "commit": "4aaacbf5e5e2218fd05eb75703fe9e0f85335803" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"catppuccin": { "branch": "main", "commit": "048c18fc531703815f5e10765ea46ce9b2c75ae4" },
"lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" },
"lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "3ba1b92b771f33256b4969d696b82c8ae7075364" },
"mason.nvim": { "branch": "main", "commit": "9c9416817c9f4e6f333c749327a1ed5355cfab61" },
"nordtheme": { "branch": "main", "commit": "f13f5dfbb784deddbc1d8195f34dfd9ec73e2295" },
"nvim-treesitter": { "branch": "master", "commit": "59d4c14a1a4262cf637ff2420032593afa062749" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "19a91a38b02c1c28c14e0ba468d20ae1423c39b2" },
"nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" },
"plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" },
"nvim-lspconfig": { "branch": "master", "commit": "8917d2c830e04bf944a699b8c41f097621283828" },
"nvim-treesitter": { "branch": "master", "commit": "cd4e0909948eb33d3959e133c16f837e4db122c6" },
"plenary.nvim": { "branch": "master", "commit": "663246936325062427597964d81d30eaa42ab1e4" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
"telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
"tokyonight.nvim": { "branch": "main", "commit": "f247ee700b569ed43f39320413a13ba9b0aef0db" },
"tokyonight.nvim": { "branch": "main", "commit": "67c6050e1ca41260c919236a098ba278472c7520" },
"vim-commentary": { "branch": "master", "commit": "f67e3e67ea516755005e6cccb178bc8439c6d402" },
"vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" },
"vim-fugitive": { "branch": "master", "commit": "854a8df0d06b8d3fcb30fa7f2b08c62b553eee3b" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" }
"vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
}
13 changes: 0 additions & 13 deletions nvim/lua/dotfiles/core/keymaps.lua

This file was deleted.

69 changes: 0 additions & 69 deletions nvim/lua/dotfiles/plugin-config.lua

This file was deleted.

17 changes: 0 additions & 17 deletions nvim/lua/dotfiles/plugins/init.lua

This file was deleted.

13 changes: 13 additions & 0 deletions nvim/lua/keymaps.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- neovim init file
-- github.com/davidjenni/dotfiles

local k = vim.keymap

k.set('n', '<leader>h', '<cmd>noh<CR>', { desc = 'Clear highlights' })
k.set('n', '<c-k>', ':wincmd k<CR>', { desc = 'Move to window above' })
k.set('n', '<c-j>', ':wincmd j<CR>', { desc = 'Move to window below' })
k.set('n', '<c-h>', ':wincmd h<CR>', { desc = 'Move to window left' })
k.set('n', '<c-l>', ':wincmd l<CR>', { desc = 'Move to window right' })

-- plugins set their own keymaps in ~/.config/nvim/lua/plugins/*.lua
--
12 changes: 11 additions & 1 deletion nvim/lua/dotfiles/lazy-nvim.lua → nvim/lua/lazy-nvim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,15 @@ if not vim.loop.fs_stat(lazypath) then
end
vim.opt.rtp:prepend(lazypath)

require('lazy').setup('dotfiles.plugins')
local opts = {
-- defaults = {
-- lazy = true,
-- },
install = {
colorscheme = { "catppuccin" },
},
}

-- merge and load all .lua files under lua/plugins, see:
-- https://github.com/folke/lazy.nvim#-structuring-your-plugins
require("lazy").setup("plugins", opts)
3 changes: 3 additions & 0 deletions nvim/lua/dotfiles/core/options.lua → nvim/lua/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ opt.swapfile = false
opt.hidden = true
opt.switchbuf = 'useopen'

-- disable folding; see also `set nofoldenable`
opt.foldlevel = 99

7 changes: 7 additions & 0 deletions nvim/lua/plugins/basics.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return {
'tpope/vim-commentary',
'tpope/vim-fugitive',
'tpope/vim-surround',
'tpope/vim-unimpaired',
{ 'nvim-tree/nvim-web-devicons', lazy = true, },
}
14 changes: 14 additions & 0 deletions nvim/lua/plugins/gitsigns.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
return {
'lewis6991/gitsigns.nvim',
event = { "BufReadPre", "BufNewFile" },
opts = {
signs = {
add = { text = "▎" },
change = { text = "▎" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "▎" },
untracked = { text = "▎" },
},
},
}
51 changes: 51 additions & 0 deletions nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
return {
{
"williamboman/mason.nvim",
config = function()
require("mason").setup()
end
},

{
"williamboman/mason-lspconfig.nvim",
config = function()
require("mason-lspconfig").setup({
ensure_installed = { "lua_ls" },
})
end
},

{
-- neodev needs to start before nvim-lspconfig
"folke/neodev.nvim",
config = function()
require("neodev").setup({})
end,
},

{
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"j-hui/fidget.nvim",
"folke/neodev.nvim",
},
config = function()
local lspconfig = require('lspconfig')
lspconfig.lua_ls.setup({})

vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = 'Show info about symbol under cursor'})
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = 'Go to definition' })
vim.keymap.set({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, { desc = 'Show code actions' })
vim.keymap.set('n', 'gr', vim.lsp.buf.references, { desc = 'Show references' })
end
},

{
"j-hui/fidget.nvim",
config = function()
require("fidget").setup({})
end
}
}
28 changes: 28 additions & 0 deletions nvim/lua/plugins/lualine.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
local config = function()
require("lualine").setup({
options = {
theme = "auto",
globalstatus = true,
component_separators = { left = "|", right = "|" },
section_separators = { left = "", right = "" },
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "filename", "buffers" },
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location", '%B' },
},
tabline = {},
})
end

return {
"nvim-lualine/lualine.nvim",
dependencies = {
'nvim-tree/nvim-web-devicons'
},
lazy = false,
config = config,
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@
--
-- neovim init file
-- github.com/davidjenni/dotfiles

return {
-- gitsigns:
{
'lewis6991/gitsigns.nvim',
event = { "BufReadPre", "BufNewFile" },
opts = {
signs = {
add = { text = "▎" },
change = { text = "▎" },
delete = { text = "" },
topdelete = { text = "" },
changedelete = { text = "▎" },
untracked = { text = "▎" },
},
},
},

-- telescope:
{
'nvim-telescope/telescope.nvim', tag = '0.1.5',
dependencies = { 'nvim-lua/plenary.nvim' },
Expand Down Expand Up @@ -53,21 +32,37 @@ return {
{ "<leader>sm", "<cmd>Telescope marks<cr>", desc = "Jump to Mark" },
{ "<leader>so", "<cmd>Telescope vim_options<cr>", desc = "Options" },
{ "<leader>sR", "<cmd>Telescope resume<cr>", desc = "Resume" },
}
},
},

-- treesitter:
{
'nvim-treesitter/nvim-treesitter',
dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects',
},
build = ":TSUpdate",
},
"nvim-telescope/telescope-ui-select.nvim",
config = function()
local telescope = require("telescope")
telescope.setup({
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown {
-- even more opts
}

-- devicons:
{
'nvim-tree/nvim-web-devicons',
lazy = true,
-- pseudo code / specification for writing custom displays, like the one
-- for "codeactions"
-- specific_opts = {
-- [kind] = {
-- make_indexed = function(items) -> indexed_items, width,
-- make_displayer = function(widths) -> displayer
-- make_display = function(displayer) -> function(e)
-- make_ordinal = function(e) -> string
-- },
-- -- for example to disable the custom builtin "codeactions" display
-- do the following
-- codeactions = false,
-- }
}
}
})

require("telescope").load_extension("ui-select")
end
},
}
Loading
Loading