initial commit: Mzansi Neovim
This commit is contained in:
4
.gitingore
Normal file
4
.gitingore
Normal file
@@ -0,0 +1,4 @@
|
||||
*.swp
|
||||
*.swo
|
||||
undo/
|
||||
view/
|
||||
3
init.lua
Normal file
3
init.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
require('config.options')
|
||||
require('config.keybinds')
|
||||
require('config.lazy')
|
||||
23
lazy-lock.json
Normal file
23
lazy-lock.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"LuaSnip": { "branch": "master", "commit": "dae4f5aaa3574bd0c2b9dd20fb9542a02c10471c" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
|
||||
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" },
|
||||
"flutter-tools.nvim": { "branch": "main", "commit": "677cc07c16e8b89999108d2ebeefcfc5f539b73c" },
|
||||
"harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "a676ab7282da8d651e175118bcf54483ca11e46d" },
|
||||
"mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "dc2f86d2b66a6e01a98c37cdadd3be3e90f8ab9a" },
|
||||
"nvim-treesitter": { "branch": "main", "commit": "2cc172c28e5550e00e6beead4599b1469469c1c7" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" },
|
||||
"tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" },
|
||||
"vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }
|
||||
}
|
||||
2
lua/config/keybinds.lua
Normal file
2
lua/config/keybinds.lua
Normal file
@@ -0,0 +1,2 @@
|
||||
vim.g.mapleader = " "
|
||||
vim.keymap.set("n", "<leader>cd", vim.cmd.Ex)
|
||||
23
lua/config/lazy.lua
Normal file
23
lua/config/lazy.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
{ import = "plugins" },
|
||||
},
|
||||
-- remove change notifications
|
||||
-- change_detection = { notify = false },
|
||||
})
|
||||
4
lua/config/options.lua
Normal file
4
lua/config/options.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
vim.opt.number = true
|
||||
vim.opt.cursorline = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.shiftwidth = 4
|
||||
23
lua/plugins/colors.lua
Normal file
23
lua/plugins/colors.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
local function enable_transparency()
|
||||
vim.api.nvim_set_hl(0, "Normal", {bg = "none"})
|
||||
end
|
||||
return {
|
||||
{
|
||||
"folke/tokyonight.nvim",
|
||||
lazy = false,
|
||||
priority = 1000,
|
||||
config = function()
|
||||
vim.cmd([[colorscheme tokyonight]])
|
||||
enable_transparency()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
dependencies = {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
opts = {
|
||||
theme = 'tokyonight',
|
||||
}
|
||||
}
|
||||
}
|
||||
44
lua/plugins/harpoon.lua
Normal file
44
lua/plugins/harpoon.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
local conf = require("telescope.config").values
|
||||
local function toggle_telescope(harpoon_files)
|
||||
local file_paths = {}
|
||||
for _, item in ipairs(harpoon_files.items) do
|
||||
table.insert(file_paths, item.value)
|
||||
end
|
||||
|
||||
require("telescope.pickers").new({}, {
|
||||
promt_title = "Harpoon Finder",
|
||||
finder = require("telescope.finders").new_table({
|
||||
results = file_paths,
|
||||
}),
|
||||
previewer = conf.file_previewer({}),
|
||||
sorter = conf.generic_sorter({}),
|
||||
}):find()
|
||||
end
|
||||
|
||||
return {
|
||||
"ThePrimeagen/harpoon",
|
||||
branch = "harpoon2",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
local harpoon = require("harpoon")
|
||||
|
||||
-- REQUIRED
|
||||
harpoon:setup()
|
||||
-- REQUIRED
|
||||
|
||||
-- Basic UI and file management keymaps
|
||||
vim.keymap.set("n", "<leader>a", function() harpoon:list():add() end, { desc = "Harpoon Add File" })
|
||||
vim.keymap.set("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end, { desc = "Harpoon Menu" })
|
||||
vim.keymap.set("n", "<leader>fl", function() toggle_telescope(harpoon:list()) end,{ desc = "Open harpoon window" })
|
||||
|
||||
-- Quick navigation to files 1-4
|
||||
vim.keymap.set("n", "<C-h>", function() harpoon:list():select(1) end, { desc = "Harpoon File 1" })
|
||||
vim.keymap.set("n", "<C-t>", function() harpoon:list():select(2) end, { desc = "Harpoon File 2" })
|
||||
vim.keymap.set("n", "<C-n>", function() harpoon:list():select(3) end, { desc = "Harpoon File 3" })
|
||||
vim.keymap.set("n", "<C-s>", function() harpoon:list():select(4) end, { desc = "Harpoon File 4" })
|
||||
|
||||
-- Toggle previous & next buffers stored within Harpoon list
|
||||
vim.keymap.set("n", "<C-S-P>", function() harpoon:list():prev() end, { desc = "Harpoon Prev" })
|
||||
vim.keymap.set("n", "<C-S-N>", function() harpoon:list():next() end, { desc = "Harpoon Next" })
|
||||
end,
|
||||
}
|
||||
120
lua/plugins/lsp.lua
Normal file
120
lua/plugins/lsp.lua
Normal file
@@ -0,0 +1,120 @@
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
config = function()
|
||||
require("mason").setup()
|
||||
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
-- We no longer need: local lspconfig = require("lspconfig")
|
||||
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
local servers = {
|
||||
"lua_ls",
|
||||
"pyright",
|
||||
"dockerls",
|
||||
"bashls",
|
||||
"yamlls",
|
||||
"jsonls",
|
||||
"html",
|
||||
"cssls",
|
||||
"eslint",
|
||||
"sqls",
|
||||
"marksman",
|
||||
}
|
||||
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = servers,
|
||||
})
|
||||
|
||||
-- Neovim 0.11+ approach: Use vim.lsp.config
|
||||
for _, server_name in ipairs(servers) do
|
||||
local config = {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
if server_name == "lua_ls" then
|
||||
config.settings = {
|
||||
Lua = {
|
||||
diagnostics = { globals = { "vim" } },
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
-- Enable the server configuration natively
|
||||
vim.lsp.config(server_name, config)
|
||||
vim.lsp.enable(server_name)
|
||||
end
|
||||
|
||||
-- Keybindings (unchanged)
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(ev)
|
||||
local opts = { buffer = ev.buf }
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-flutter/flutter-tools.nvim",
|
||||
lazy = false, -- Load on startup to ensure it handles dartls correctly
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"stevearc/dressing.nvim", -- Optional but highly recommended for better UI
|
||||
},
|
||||
config = function()
|
||||
require("flutter-tools").setup({
|
||||
lsp = {
|
||||
-- Pass your existing capabilities to the flutter-tools LSP config
|
||||
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||
-- You can add specific dartls settings here if needed
|
||||
settings = {
|
||||
showTodos = true,
|
||||
completeFunctionCalls = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"L3MON4D3/LuaSnip", -- Snippet engine is usually required by cmp configs
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
},
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
6
lua/plugins/oneliners.lua
Normal file
6
lua/plugins/oneliners.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
return {
|
||||
{
|
||||
-- Git Plugin
|
||||
'tpope/vim-fugitive',
|
||||
},
|
||||
}
|
||||
15
lua/plugins/telescope.lua
Normal file
15
lua/plugins/telescope.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
return {
|
||||
'nvim-telescope/telescope.nvim', version = '*',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
-- optional but recommended
|
||||
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
|
||||
},
|
||||
config = function()
|
||||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
|
||||
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
|
||||
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' })
|
||||
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
|
||||
end
|
||||
}
|
||||
31
lua/plugins/treesitter.lua
Normal file
31
lua/plugins/treesitter.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
lazy = false,
|
||||
build = ":TSUpdate",
|
||||
config = function()
|
||||
require("nvim-treesitter").setup({
|
||||
install_dir = vim.fn.stdpath("data") .. "/site",
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
autotag = { enable = true },
|
||||
ensure_installed = {
|
||||
"lua",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"query",
|
||||
"dart",
|
||||
"python",
|
||||
"dockerfile",
|
||||
"yaml",
|
||||
"bash",
|
||||
"json",
|
||||
"html",
|
||||
"css",
|
||||
"javascript",
|
||||
"sql",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user