nvim
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
require('core.keymaps')
|
||||
require('core.settings')
|
||||
@@ -0,0 +1,78 @@
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
-- Keymaps for better default experience
|
||||
vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { silent = true })
|
||||
|
||||
-- Space + s saves the file
|
||||
vim.keymap.set("n", "<Leader>s", ":write<CR>", { silent = true })
|
||||
|
||||
-- Move normally between wrapped lines
|
||||
vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
||||
vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
||||
|
||||
-- Shift + q - Quit
|
||||
vim.keymap.set("n", "Q", "<C-W>q")
|
||||
|
||||
-- vv - Makes vertical split
|
||||
vim.keymap.set("n", "vv", "<C-W>v")
|
||||
-- ss - Makes horizontal split
|
||||
vim.keymap.set("n", "ss", "<C-W>s")
|
||||
|
||||
-- Quick jumping between splits
|
||||
vim.keymap.set("n", "<C-j>", "<C-w>j")
|
||||
vim.keymap.set("n", "<C-k>", "<C-w>k")
|
||||
vim.keymap.set("n", "<C-h>", "<C-w>h")
|
||||
vim.keymap.set("n", "<C-l>", "<C-w>l")
|
||||
|
||||
-- Indenting in visual mode (tab/shift+tab)
|
||||
vim.keymap.set("v", "<Tab>", ">gv")
|
||||
vim.keymap.set("v", "<S-Tab>", "<gv")
|
||||
|
||||
-- Move to the end of yanked text after yank and paste
|
||||
vim.cmd("vnoremap <silent> y y`]")
|
||||
vim.cmd("vnoremap <silent> p p`]")
|
||||
vim.cmd("nnoremap <silent> p p`]")
|
||||
|
||||
-- Space + Space to clean search highlight
|
||||
vim.keymap.set("n", "<Leader>h", ":noh<CR>", { silent = true })
|
||||
|
||||
-- Fixes pasting after visual selection.
|
||||
vim.keymap.set("v", "p", '"_dP')
|
||||
|
||||
-- Select all
|
||||
vim.keymap.set("n", "<C-a>", "gg<S-v>G")
|
||||
|
||||
-- Save with root permission (not working for now)
|
||||
--vim.api.nvim_create_user_command('W', 'w !sudo tee > /dev/null %', {})
|
||||
|
||||
-- Disable continuations
|
||||
vim.keymap.set("n", "<Leader>o", "o<Esc>^Da", opts)
|
||||
vim.keymap.set("n", "<Leader>O", "O<Esc>^Da", opts)
|
||||
|
||||
-- Jumplist
|
||||
vim.keymap.set("n", "<C-m>", "<C-i>", opts)
|
||||
|
||||
-- New tab
|
||||
vim.keymap.set("n", "te", ":tabedit")
|
||||
vim.keymap.set("n", "<tab>", ":tabnext<Return>", opts)
|
||||
vim.keymap.set("n", "<s-tab>", ":tabprev<Return>", opts)
|
||||
|
||||
-- Resize window
|
||||
vim.keymap.set("n", "<C-w><left>", "<C-w><")
|
||||
vim.keymap.set("n", "<C-w><right>", "<C-w>>")
|
||||
vim.keymap.set("n", "<C-w><up>", "<C-w>+")
|
||||
vim.keymap.set("n", "<C-w><down>", "<C-w>-")
|
||||
|
||||
-- Diagnostics
|
||||
vim.keymap.set("n", "<C-j>", function()
|
||||
vim.diagnostic.goto_next()
|
||||
end, opts)
|
||||
|
||||
vim.keymap.set("n", "<leader>r", function()
|
||||
require("craftzdog.hsl").replaceHexWithHSL()
|
||||
end)
|
||||
|
||||
vim.keymap.set("n", "<leader>i", function()
|
||||
require("craftzdog.lsp").toggleInlayHints()
|
||||
end)
|
||||
@@ -0,0 +1,96 @@
|
||||
-- Set <space> as the leader key
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
-- Set highlight on search
|
||||
vim.o.hlsearch = true
|
||||
|
||||
-- Make line numbers default
|
||||
vim.wo.number = true
|
||||
|
||||
-- Enable mouse mode
|
||||
vim.o.mouse = "a"
|
||||
|
||||
-- Sync clipboard between OS and Neovim.
|
||||
vim.o.clipboard = "unnamedplus"
|
||||
|
||||
-- Enable break indent
|
||||
vim.o.breakindent = true
|
||||
|
||||
-- No swap files
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.backup = false
|
||||
vim.opt.writebackup = false
|
||||
-- Save undo history
|
||||
vim.o.undofile = true
|
||||
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
||||
|
||||
-- Case-insensitive searching UNLESS \C or capital in search
|
||||
vim.o.ignorecase = true
|
||||
vim.o.smartcase = true
|
||||
|
||||
-- Keep signcolumn on by default
|
||||
vim.wo.signcolumn = "yes"
|
||||
|
||||
-- Decrease update time
|
||||
vim.o.updatetime = 250
|
||||
vim.o.timeoutlen = 300
|
||||
|
||||
-- Set completeopt to have a better completion experience
|
||||
vim.o.completeopt = "menuone,noselect"
|
||||
|
||||
-- NOTE: You should make sure your terminal supports this
|
||||
vim.o.termguicolors = true
|
||||
|
||||
-- Don't show modes (insert/visual)
|
||||
vim.opt.showmode = true
|
||||
|
||||
-- " Open splits on the right and below
|
||||
vim.opt.splitbelow = true
|
||||
vim.opt.splitright = true
|
||||
|
||||
-- " update vim after file update from outside
|
||||
vim.opt.autoread = true
|
||||
|
||||
-- " Indentation
|
||||
vim.opt.autoindent = true
|
||||
vim.opt.smartindent = true
|
||||
vim.opt.smarttab = true
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.softtabstop = 2
|
||||
vim.opt.shiftwidth = 2
|
||||
|
||||
-- " Always use spaces insted of tabs
|
||||
vim.opt.expandtab = true
|
||||
|
||||
-- " Don't wrap lines
|
||||
vim.opt.wrap = true
|
||||
-- " Wrap lines at convenient points
|
||||
vim.opt.linebreak = true
|
||||
|
||||
-- " Show line breaks
|
||||
vim.opt.showbreak = "↳"
|
||||
|
||||
-- " Start scrolling when we'are 8 lines aways from borders
|
||||
vim.opt.scrolloff = 8
|
||||
vim.opt.sidescrolloff = 15
|
||||
vim.opt.sidescroll = 5
|
||||
|
||||
-- " This makes vim act like all other editors, buffers can
|
||||
-- " exist in the background without being in a window.
|
||||
vim.opt.hidden = true
|
||||
|
||||
-- " Add the g flag to search/replace by default
|
||||
vim.opt.gdefault = true
|
||||
|
||||
-- Lazy redraw
|
||||
vim.o.lazyredraw = true
|
||||
|
||||
-- Spell checker
|
||||
|
||||
vim.opt.spelllang = "en_us"
|
||||
vim.opt.spell = true
|
||||
|
||||
-- Remove $
|
||||
|
||||
vim.cmd("set nolist")
|
||||
@@ -0,0 +1,40 @@
|
||||
-- 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({
|
||||
spec = {
|
||||
-- import your plugins
|
||||
{ import = "plugins" },
|
||||
},
|
||||
-- Configure any other settings here. See the documentation for more details.
|
||||
-- colorscheme that will be used when installing plugins.
|
||||
|
||||
-- automatically check for plugin updates
|
||||
checker = { enabled = true, notify = false },
|
||||
change_detection = { notify = false },
|
||||
rocks = {
|
||||
enabled = false,
|
||||
hererocks = false
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
return {
|
||||
"goolord/alpha-nvim",
|
||||
dependencies = {
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
},
|
||||
|
||||
config = function()
|
||||
local alpha = require("alpha")
|
||||
local dashboard = require("alpha.themes.startify")
|
||||
|
||||
dashboard.section.header.val = {
|
||||
[[▐▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▌]],
|
||||
[[▐ ▄▄▄ ██ ▄█▀ ██▓ ██▓▓█████▄ ▄▄▄██▀▀▀██ ▄█▀▌]],
|
||||
[[▐▒████▄ ██▄█▒ ▓██▒▓██▒▒██▀ ██▌ ▒██ ██▄█▒ ▌]],
|
||||
[[▐▒██ ▀█▄ ▓███▄░ ▒██▒▒██▒░██ █▌ ░██ ▓███▄░ ▌]],
|
||||
[[▐░██▄▄▄▄██ ▓██ █▄ ░██░░██░░▓█▄ ▌▓██▄██▓ ▓██ █▄ ▌]],
|
||||
[[▐ ▓█ ▓██▒▒██▒ █▄░██░░██░░▒████▓ ▓███▒ ▒██▒ █▄▌]],
|
||||
[[▐ ▒▒ ▓▒█░▒ ▒▒ ▓▒░▓ ░▓ ▒▒▓ ▒ ▒▓▒▒░ ▒ ▒▒ ▓▒▌]],
|
||||
[[▐ ▒ ▒▒ ░░ ░▒ ▒░ ▒ ░ ▒ ░ ░ ▒ ▒ ▒ ░▒░ ░ ░▒ ▒░▌]],
|
||||
[[▐ ░ ▒ ░ ░░ ░ ▒ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ▌]],
|
||||
[[▐ ░ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ▌]],
|
||||
[[▐ ░ ▌]],
|
||||
[[▐▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▌]],
|
||||
}
|
||||
|
||||
alpha.setup(dashboard.opts)
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
return {
|
||||
"navarasu/onedark.nvim",
|
||||
priority = 1000,
|
||||
config = function()
|
||||
require('onedark').setup {
|
||||
-- Main options --
|
||||
style = 'dark', -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light'
|
||||
transparent = false, -- Show/hide background
|
||||
term_colors = true, -- Change terminal color as per the selected theme style
|
||||
ending_tildes = false, -- Show the end-of-buffer tildes. By default they are hidden
|
||||
cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu
|
||||
|
||||
-- toggle theme style ---
|
||||
toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
|
||||
toggle_style_list = {'dark', 'darker', 'cool', 'deep', 'warm', 'warmer', 'light'}, -- List of styles to toggle between
|
||||
|
||||
-- Change code style ---
|
||||
-- Options are italic, bold, underline, none
|
||||
-- You can configure multiple style with comma separated, For e.g., keywords = 'italic,bold'
|
||||
code_style = {
|
||||
comments = 'italic',
|
||||
keywords = 'none',
|
||||
functions = 'none',
|
||||
strings = 'none',
|
||||
variables = 'none'
|
||||
},
|
||||
|
||||
-- Lualine options --
|
||||
lualine = {
|
||||
transparent = false, -- lualine center bar transparency
|
||||
},
|
||||
|
||||
-- Custom Highlights --
|
||||
colors = {}, -- Override default colors
|
||||
highlights = {}, -- Override highlight groups
|
||||
|
||||
-- Plugins Config --
|
||||
diagnostics = {
|
||||
darker = true, -- darker colors for diagnostic
|
||||
undercurl = true, -- use undercurl instead of underline for diagnostics
|
||||
background = true, -- use background color for virtual text
|
||||
},
|
||||
}
|
||||
vim.cmd([[
|
||||
colorscheme onedark
|
||||
]])
|
||||
end
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
return {
|
||||
"numToStr/Comment.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
"JoosepAlviste/nvim-ts-context-commentstring",
|
||||
},
|
||||
config = function()
|
||||
local comment = require("Comment")
|
||||
|
||||
local ts_context_commentstring = require("ts_context_commentstring.integrations.comment_nvim")
|
||||
|
||||
comment.setup({
|
||||
-- for commenting tsx and jsx files
|
||||
pre_hook = ts_context_commentstring.create_pre_hook(),
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
return {
|
||||
"ibhagwan/fzf-lua",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("fzf-lua").setup({
|
||||
colorscheme = "onedark",
|
||||
winopts = {
|
||||
fullscreen = true,
|
||||
preview = {
|
||||
layout = "vertical",
|
||||
vertical = "up:45%", -- up|down:size
|
||||
},
|
||||
},
|
||||
fzf_opts = {
|
||||
["--keep-right"] = "", -- https://github.com/ibhagwan/fzf-lua/issues/269
|
||||
["--layout"] = "default",
|
||||
-- ["--ansi"] = false,
|
||||
},
|
||||
keymap = {
|
||||
fzf = {
|
||||
["ctrl-r"] = "select-all+accept", -- https://github.com/ibhagwan/fzf-lua/issues/324
|
||||
},
|
||||
},
|
||||
files = {
|
||||
git_icons = true,
|
||||
file_icons = true,
|
||||
},
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<c-P>", "<cmd>lua require('fzf-lua').files()<CR>", { silent = true })
|
||||
|
||||
vim.keymap.set("n", "<leader>b", "<cmd>lua require('fzf-lua').buffers()<CR>", { desc = "Fuzzy find recent files" })
|
||||
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<leader>/",
|
||||
"<cmd>lua require('fzf-lua').live_grep_resume()<CR>",
|
||||
{ desc = "Find string in cwd" }
|
||||
)
|
||||
|
||||
vim.keymap.set("n", "gr", ":FzfLua lsp_references<CR>")
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
return {
|
||||
"dinhhuy258/git.nvim",
|
||||
event = "BufReadPre",
|
||||
opts = {
|
||||
keymaps = {
|
||||
-- Open blame window
|
||||
blame = "<Leader>gb",
|
||||
-- Open file/folder in git repository
|
||||
browse = "<Leader>go",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
return {
|
||||
"b0o/incline.nvim",
|
||||
dependencies = { "navarasu/onedark.nvim", "kyazdani42/nvim-web-devicons", "lewis6991/gitsigns.nvim" },
|
||||
event = "BufReadPre",
|
||||
priority = 1200,
|
||||
config = function()
|
||||
local devicons = require("nvim-web-devicons")
|
||||
|
||||
require("incline").setup {
|
||||
render = function(props)
|
||||
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ':t')
|
||||
if filename == '' then
|
||||
filename = '[No Name]'
|
||||
end
|
||||
local ft_icon, ft_color = devicons.get_icon_color(filename)
|
||||
|
||||
local function get_git_diff()
|
||||
local icons = { removed = '', changed = '', added = '' }
|
||||
local signs = vim.b[props.buf].gitsigns_status_dict
|
||||
local labels = {}
|
||||
if signs == nil then
|
||||
return labels
|
||||
end
|
||||
for name, icon in pairs(icons) do
|
||||
if tonumber(signs[name]) and signs[name] > 0 then
|
||||
table.insert(labels, { icon .. signs[name] .. ' ', group = 'Diff' .. name })
|
||||
end
|
||||
end
|
||||
if #labels > 0 then
|
||||
table.insert(labels, { '┊ ' })
|
||||
end
|
||||
return labels
|
||||
end
|
||||
|
||||
local function get_diagnostic_label()
|
||||
local icons = { error = '', warn = '', info = '', hint = '' }
|
||||
local label = {}
|
||||
|
||||
for severity, icon in pairs(icons) do
|
||||
local n = #vim.diagnostic.get(props.buf, { severity = vim.diagnostic.severity[string.upper(severity)] })
|
||||
if n > 0 then
|
||||
table.insert(label, { icon .. n .. ' ', group = 'DiagnosticSign' .. severity })
|
||||
end
|
||||
end
|
||||
if #label > 0 then
|
||||
table.insert(label, { '┊ ' })
|
||||
end
|
||||
return label
|
||||
end
|
||||
|
||||
return {
|
||||
{ get_diagnostic_label() },
|
||||
{ get_git_diff() },
|
||||
{ (ft_icon or '') .. ' ', guifg = ft_color, guibg = 'none' },
|
||||
{ filename .. ' ', gui = vim.bo[props.buf].modified and 'bold,italic' or 'bold' },
|
||||
{ '┊ ' .. vim.api.nvim_win_get_number(props.win), group = 'DevIconWindows' },
|
||||
}
|
||||
end,
|
||||
}
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
return {
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
main = "ibl",
|
||||
opts = {},
|
||||
config = function()
|
||||
require("ibl").setup({
|
||||
scope = { enabled = false },
|
||||
indent = { char = "|" },
|
||||
})
|
||||
end
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
options = {
|
||||
-- globalstatus = false,
|
||||
theme = "onedark",
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
return {
|
||||
"williamboman/mason.nvim",
|
||||
dependencies = {
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
},
|
||||
config = function()
|
||||
local mason = require("mason")
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
local mason_tool_installer = require("mason-tool-installer")
|
||||
|
||||
mason.setup({})
|
||||
|
||||
-- Repo with all lsp server: https://github.com/williamboman/mason-lspconfig.nvim?tab=readme-ov-file#available-lsp-servers
|
||||
mason_lspconfig.setup({
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"html",
|
||||
"cssls",
|
||||
"dockerls",
|
||||
"docker_compose_language_service",
|
||||
"rust_analyzer",
|
||||
"jsonls",
|
||||
"markdown_oxide",
|
||||
"tailwindcss",
|
||||
},
|
||||
automatic_installation = true,
|
||||
})
|
||||
|
||||
mason_tool_installer.setup({
|
||||
ensure_installed = {
|
||||
"prettier",
|
||||
"stylua",
|
||||
"eslint_d",
|
||||
"prettierd",
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
-- Go forward/backward with square brackets
|
||||
return {
|
||||
"echasnovski/mini.bracketed",
|
||||
event = "BufReadPost",
|
||||
config = function()
|
||||
local bracketed = require("mini.bracketed")
|
||||
bracketed.setup({
|
||||
file = { suffix = "" },
|
||||
window = { suffix = "" },
|
||||
quickfix = { suffix = "" },
|
||||
yank = { suffix = "" },
|
||||
treesitter = { suffix = "n" },
|
||||
})
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
return {
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
branch = "v3.x",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"MunifTanjim/nui.nvim",
|
||||
},
|
||||
config = function()
|
||||
vim.keymap.set("n", "<C-n>", ":Neotree filesystem reveal left<CR>", {})
|
||||
vim.keymap.set("n", "<leader>bf", ":Neotree buffers reveal float<CR>", {})
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
return {
|
||||
"nvimtools/none-ls.nvim",
|
||||
config = function()
|
||||
local null_ls = require("null-ls")
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.formatting.prettier,
|
||||
null_ls.builtins.diagnostics.erb_lint,
|
||||
null_ls.builtins.diagnostics.rubocop,
|
||||
null_ls.builtins.formatting.rubocop,
|
||||
},
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>gf", vim.lsp.buf.format, {})
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
return {
|
||||
"windwp/nvim-autopairs",
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
"hrsh7th/nvim-cmp",
|
||||
},
|
||||
config = function()
|
||||
local autopairs = require("nvim-autopairs")
|
||||
|
||||
autopairs.setup({
|
||||
check_ts = true, -- enable treesitter
|
||||
ts_config = {
|
||||
lua = { "string" }, -- don't add pairs in lua string treesitter nodes
|
||||
javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes
|
||||
java = false, -- don't check treesitter on java
|
||||
},
|
||||
})
|
||||
|
||||
-- import nvim-autopairs completion functionality
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
|
||||
-- import nvim-cmp plugin (completions plugin)
|
||||
local cmp = require("cmp")
|
||||
|
||||
-- make autopairs and completion work together
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
return {
|
||||
{
|
||||
"hrsh7th/cmp-nvim-lsp"
|
||||
},
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
dependencies = {
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"rafamadriz/friendly-snippets",
|
||||
},
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" }, -- For luasnip users.
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
enabled = true,
|
||||
config = function()
|
||||
local lspconfig = require("lspconfig")
|
||||
local util = require("lspconfig.util")
|
||||
local cmp_nvim_lsp = require("cmp_nvim_lsp")
|
||||
|
||||
-- Disable inline error messages
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
float = {
|
||||
border = "single",
|
||||
},
|
||||
})
|
||||
|
||||
-- Add border to floating window
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] =
|
||||
vim.lsp.buf.hover({ border = "single", silent = true })
|
||||
vim.lsp.handlers["textDocument/hover"] =
|
||||
vim.lsp.buf.hover({ border = "single", silend = true })
|
||||
|
||||
-- Make float window transparent start
|
||||
|
||||
local set_hl_for_floating_window = function()
|
||||
vim.api.nvim_set_hl(0, "NormalFloat", {
|
||||
link = "Normal",
|
||||
})
|
||||
vim.api.nvim_set_hl(0, "FloatBorder", {
|
||||
bg = "none",
|
||||
})
|
||||
end
|
||||
|
||||
set_hl_for_floating_window()
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "*",
|
||||
desc = "Avoid overwritten by loading color schemes later",
|
||||
callback = set_hl_for_floating_window,
|
||||
})
|
||||
|
||||
-- Make float window transparent end
|
||||
|
||||
local on_attach = function(client, bufnr)
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"K",
|
||||
vim.lsp.buf.hover,
|
||||
{ buffer = bufnr, desc = "Show documentation for what is under cursor" }
|
||||
)
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, { buffer = bufnr, desc = "Smart rename" })
|
||||
vim.keymap.set(
|
||||
{ "n", "v" },
|
||||
"gf",
|
||||
vim.lsp.buf.code_action,
|
||||
{ buffer = bufnr, desc = "See available code actions" }
|
||||
)
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<leader>d",
|
||||
vim.diagnostic.open_float,
|
||||
{ buffer = bufnr, desc = "Show diagnostics for line" }
|
||||
)
|
||||
-- vim.keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", {buffer = bufnr, desc = 'Show definition, references'})
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, { buffer = bufnr, desc = "Go to definition" })
|
||||
end
|
||||
|
||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||
local signs = { Error = "✖", Warn = "", Hint = "", Info = "" }
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
||||
end
|
||||
|
||||
-- List config:
|
||||
|
||||
-- configure html server
|
||||
lspconfig["html"].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
|
||||
-- configure lua server (with special settings)
|
||||
lspconfig["lua_ls"].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = { -- custom settings for lua
|
||||
Lua = {
|
||||
-- make the language server recognize "vim" global
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
-- make language server aware of runtime files
|
||||
library = {
|
||||
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
|
||||
[vim.fn.stdpath("config") .. "/lua"] = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- configure css server
|
||||
lspconfig["cssls"].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
|
||||
lspconfig["ruff_lsp"].setup({})
|
||||
lspconfig["rust_analyzer"].setup({})
|
||||
lspconfig["dockerls"].setup({})
|
||||
lspconfig["jsonls"].setup({})
|
||||
lspconfig["markdown_oxide"].setup({})
|
||||
lspconfig["docker_compose_language_service"].setup({})
|
||||
lspconfig["svelte"].setup({})
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
branch = "master",
|
||||
lazy = false,
|
||||
build = ":TSUpdate",
|
||||
config = function()
|
||||
require('nvim-treesitter.configs').setup({
|
||||
ensure_installed = { "lua", "vim", "vimdoc", "python", "go", "typescript", "javascript" },
|
||||
sync_install = false,
|
||||
auto_install = true,
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
|
||||
indent = {
|
||||
enable = true
|
||||
}
|
||||
})
|
||||
end
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
-- Refactoring tool
|
||||
return {
|
||||
"ThePrimeagen/refactoring.nvim",
|
||||
keys = {
|
||||
{
|
||||
"<leader>r",
|
||||
function()
|
||||
require("refactoring").select_refactor()
|
||||
end,
|
||||
mode = "v",
|
||||
noremap = true,
|
||||
silent = true,
|
||||
expr = false,
|
||||
},
|
||||
},
|
||||
opts = {},
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Incremental rename
|
||||
return {
|
||||
"smjonas/inc-rename.nvim",
|
||||
cmd = "IncRename",
|
||||
config = true,
|
||||
}
|
||||
Reference in New Issue
Block a user