Improved neovim config
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system({
|
||||
@ -12,7 +11,6 @@ if not vim.loop.fs_stat(lazypath) then
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- Setup package manager
|
||||
require("lazy").setup("plugins", {
|
||||
defaults = {
|
||||
lazy = true,
|
||||
@ -23,12 +21,33 @@ require("lazy").setup("plugins", {
|
||||
performance = {
|
||||
rtp = {
|
||||
disabled_plugins = {
|
||||
"gzip",
|
||||
"netrwPlugin",
|
||||
"tarPlugin",
|
||||
"2html_plugin",
|
||||
"tohtml",
|
||||
"tutor",
|
||||
"getscript",
|
||||
"getscriptPlugin",
|
||||
"gzip",
|
||||
"logipat",
|
||||
"netrw",
|
||||
"netrwPlugin",
|
||||
"netrwSettings",
|
||||
"netrwFileHandlers",
|
||||
"matchit",
|
||||
"tar",
|
||||
"tarPlugin",
|
||||
"rrhelper",
|
||||
"spellfile_plugin",
|
||||
"vimball",
|
||||
"vimballPlugin",
|
||||
"zip",
|
||||
"zipPlugin",
|
||||
"tutor",
|
||||
"rplugin",
|
||||
"syntax",
|
||||
"synmenu",
|
||||
"optwin",
|
||||
"compiler",
|
||||
"bugreport",
|
||||
"ftplugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -3,10 +3,16 @@ local map = function(mode, lhs, rhs, info)
|
||||
end
|
||||
|
||||
-- Basics
|
||||
map("n", "<C-n>", "<cmd>enew<cr>", "New File")
|
||||
map({ "i", "n", "s", "v" }, "<C-s>", "<cmd>w<cr><esc>", "Save file")
|
||||
map("n", "<C-q>", "<cmd>qa<cr>", "Quit all")
|
||||
map("n", ";", ":", "Command mode")
|
||||
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", "Clear search")
|
||||
map({ "i", "n", "s", "v" }, "<C-s>", "<cmd>w<cr><esc>", "Save file")
|
||||
map("n", "U", "<cmd>redo<cr>", "Redo")
|
||||
map("n", "<C-n>", "<cmd>enew<cr>", "New File")
|
||||
map("n", "<C-r>", ":%s/<C-R><C-W>//g<Left><Left>", "Replace word under cursor")
|
||||
map("n", "<C-q>", "<cmd>qa<cr>", "Quit all")
|
||||
map({"n", "v"}, "<C-b>", "^", "Beginning of line")
|
||||
map("i", "<C-b>", "<esc>^i", "Beginning of line")
|
||||
map({"i", "n", "v"}, "<C-e>", "<end>", "End of line")
|
||||
|
||||
-- Indenting
|
||||
map("v", "<", "<gv")
|
||||
@ -17,13 +23,6 @@ map("n", "gd", vim.lsp.buf.definition, "Go to definition")
|
||||
map("n", "gr", vim.lsp.buf.references, "Go to references")
|
||||
map("n", "<leader>cf", vim.lsp.buf.format, "Format")
|
||||
|
||||
-- Toggle comment
|
||||
map("n", "<C-_>", "<cmd>lua require('Comment.api').toggle.linewise.current()<cr>", "Toggle comment")
|
||||
map("v", "<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", "Toggle comment")
|
||||
|
||||
-- Normal mode
|
||||
map("n", "<C-b>", "<cmd>NvimTreeToggle<cr>", "Toggle tree")
|
||||
-- Plugins
|
||||
map("n", "<leader>t", "<cmd>NvimTreeToggle<cr>", "Toggle tree")
|
||||
map("n", "<leader>l", "<cmd>Lazy<cr>", "Lazy")
|
||||
map("n", "<leader>f", "<cmd>Telescope find_files<cr>", "Find files")
|
||||
map("n", "<leader>r", "<cmd>Telescope oldfiles<cr>", "Recent files")
|
||||
map({ "n", "t" }, "<A-i>", "<cmd>lua require('nvterm.terminal').toggle('float')<cr>", "Toggle terminal")
|
||||
|
@ -1,8 +1,12 @@
|
||||
-- Globals
|
||||
local g = vim.g
|
||||
g.mapleader = " "
|
||||
g.loaded_netrw = 1
|
||||
g.loaded_netrwPlugin = 1
|
||||
|
||||
for _, provider in ipairs { "node", "perl", "python3", "ruby" } do
|
||||
g["loaded_" .. provider .. "_provider"] = 0
|
||||
end
|
||||
|
||||
-- Options
|
||||
local opt = vim.opt
|
||||
opt.autoindent = true
|
||||
opt.autowrite = false
|
||||
@ -16,13 +20,11 @@ opt.grepprg = "rg --vimgrep"
|
||||
opt.ignorecase = false
|
||||
opt.laststatus = 0
|
||||
opt.mouse = "a"
|
||||
opt.number = true
|
||||
opt.relativenumber = false
|
||||
opt.ruler = false
|
||||
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" }
|
||||
opt.shiftwidth = 4
|
||||
opt.shortmess:append "sI"
|
||||
opt.showmode = false
|
||||
opt.signcolumn = "yes"
|
||||
opt.smartindent = true
|
||||
opt.softtabstop = 4
|
||||
opt.spell = false
|
||||
@ -35,3 +37,9 @@ opt.undolevels = 10000
|
||||
opt.updatetime = 250
|
||||
opt.wildmode = "longest:full,full"
|
||||
opt.wrap = false
|
||||
|
||||
-- UI
|
||||
opt.fillchars = { eob = " ", vert = " " }
|
||||
opt.number = true
|
||||
opt.relativenumber = false
|
||||
opt.signcolumn = "yes:1"
|
||||
|
@ -1,6 +1,9 @@
|
||||
return {
|
||||
"numToStr/Comment.nvim",
|
||||
event = "VeryLazy",
|
||||
keys = {
|
||||
{"<C-_>", "<cmd>lua require('Comment.api').toggle.linewise.current()<cr>", desc = "Toggle comment"},
|
||||
{"<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", mode = "v", desc = "Toggle comment"},
|
||||
},
|
||||
config = true,
|
||||
opts = {
|
||||
mappings = {
|
||||
|
7
.config/nvim/lua/plugins/flash.lua
Normal file
7
.config/nvim/lua/plugins/flash.lua
Normal file
@ -0,0 +1,7 @@
|
||||
return {
|
||||
"folke/flash.nvim",
|
||||
keys = {
|
||||
{ "s", function() require("flash").jump() end, mode = { "n", "x", "o" }, desc = "Flash" },
|
||||
{ "S", function() require("flash").treesitter() end, mode = { "n", "o", "x" }, desc = "Flash Treesitter" },
|
||||
},
|
||||
}
|
@ -1,24 +1,49 @@
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
opts = {
|
||||
servers = {
|
||||
lua_ls = {},
|
||||
gopls = {},
|
||||
|
||||
-- web dev
|
||||
--cssls = {},
|
||||
--html = {},
|
||||
--jsonls = {},
|
||||
--tsserver = {},
|
||||
--svelte = {},
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
"folke/neodev.nvim",
|
||||
},
|
||||
opts = {
|
||||
servers = {
|
||||
gopls = {},
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
--cssls = {},
|
||||
--html = {},
|
||||
--jsonls = {},
|
||||
--tsserver = {},
|
||||
--svelte = {},
|
||||
},
|
||||
config = function(_, opts)
|
||||
local servers = opts.servers
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("neodev").setup()
|
||||
|
||||
for server, server_opts in pairs(servers) do
|
||||
require("lspconfig")[server].setup(server_opts)
|
||||
end
|
||||
end,
|
||||
}
|
||||
-- Servers
|
||||
local servers = opts.servers
|
||||
|
||||
for server, server_opts in pairs(servers) do
|
||||
require("lspconfig")[server].setup(server_opts)
|
||||
end
|
||||
|
||||
-- Icons
|
||||
local icons = {
|
||||
Error = " ",
|
||||
Warn = " ",
|
||||
Hint = " ",
|
||||
Info = " ",
|
||||
}
|
||||
|
||||
for name, icon in pairs(icons) do
|
||||
name = "DiagnosticSign" .. name
|
||||
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
7
.config/nvim/lua/plugins/nvterm.lua
Normal file
7
.config/nvim/lua/plugins/nvterm.lua
Normal file
@ -0,0 +1,7 @@
|
||||
return {
|
||||
"NvChad/nvterm",
|
||||
keys = {
|
||||
{ "<A-i>", "<cmd>lua require('nvterm.terminal').toggle('float')<cr>", mode = { "n", "t" }, desc = "Toggle terminal" },
|
||||
},
|
||||
config = true,
|
||||
}
|
7
.config/nvim/lua/plugins/spectre.lua
Normal file
7
.config/nvim/lua/plugins/spectre.lua
Normal file
@ -0,0 +1,7 @@
|
||||
return {
|
||||
"nvim-pack/nvim-spectre",
|
||||
keys = {
|
||||
{ "<leader>sr", function() require("spectre").open() end, desc = "Replace in files (Spectre)" },
|
||||
},
|
||||
config = true,
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
return {
|
||||
"nvim-telescope/telescope-file-browser.nvim",
|
||||
enabled = false,
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
"nvim-lua/plenary.nvim"
|
||||
},
|
||||
config = function()
|
||||
require("telescope").load_extension("file_browser")
|
||||
vim.keymap.set("n", "<leader>fb", "<cmd>Telescope file_browser<cr>", "File browser")
|
||||
end,
|
||||
}
|
@ -1,8 +1,27 @@
|
||||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
event = "VeryLazy",
|
||||
config = true,
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim"
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-telescope/telescope-project.nvim",
|
||||
},
|
||||
keys = {
|
||||
{"<leader>f", "<cmd>Telescope find_files<cr>", desc = "Find files"},
|
||||
{"<leader>r", "<cmd>Telescope oldfiles<cr>", desc = "Recent files"},
|
||||
{"<leader>p", "<cmd>Telescope project<cr>", desc = "Projects"},
|
||||
},
|
||||
config = function()
|
||||
require("telescope").setup({
|
||||
extensions = {
|
||||
project = {
|
||||
base_dirs = {
|
||||
{ path = "~/projects", max_depth = 2 },
|
||||
},
|
||||
order_by = "desc",
|
||||
sync_with_nvim_tree = true,
|
||||
theme = "dropdown",
|
||||
},
|
||||
},
|
||||
})
|
||||
require("telescope").load_extension("project")
|
||||
end,
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
return {
|
||||
"NvChad/nvterm",
|
||||
event = "VeryLazy",
|
||||
config = true,
|
||||
}
|
@ -5,6 +5,7 @@ return {
|
||||
opts = {
|
||||
style = "dark",
|
||||
transparent = false,
|
||||
term_colors = true,
|
||||
},
|
||||
config = function(_, opts)
|
||||
local theme = require("onedark")
|
||||
|
@ -4,14 +4,26 @@ return {
|
||||
dependencies = {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
config = function()
|
||||
require("nvim-tree").setup({
|
||||
view = {
|
||||
width = 35,
|
||||
},
|
||||
renderer = {
|
||||
root_folder_label = false
|
||||
},
|
||||
})
|
||||
opts = {
|
||||
filesystem_watchers = {
|
||||
enable = true,
|
||||
},
|
||||
filters = {
|
||||
dotfiles = false,
|
||||
},
|
||||
renderer = {
|
||||
root_folder_label = false
|
||||
},
|
||||
sync_root_with_cwd = true,
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
update_root = false,
|
||||
},
|
||||
view = {
|
||||
width = 35,
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("nvim-tree").setup(opts)
|
||||
end,
|
||||
}
|
||||
|
Reference in New Issue
Block a user