Compare commits

..

6 Commits

52 changed files with 375 additions and 252 deletions

View File

@ -1,3 +1,6 @@
require("options")
require("keymaps")
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ vim.fn.system({
@ -11,15 +14,6 @@ if not vim.loop.fs_stat(lazypath) then
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require("options") require("lazy").setup({ { import = "plugins" }, { import = "plugins.lsp" }, { import = "plugins.themes" } })
require("keymaps")
require("lazy").setup("plugins")
require("luasnip.loaders.from_vscode").lazy_load()
vim.cmd "colorscheme rose-pine"
require('Comment').setup() vim.cmd("colorscheme rose-pine")
require("setup/lualine")
require("setup/bufferline")
require("setup/nvim-cmp")
require("setup/lsp")
require("setup/toggle-diagnostics")

View File

@ -17,49 +17,49 @@ map("n", "<leader>d", ":ToggleDiag<cr>") -- toggle all diagnostics
vim.api.nvim_create_autocmd('LspAttach', { -- vim.api.nvim_create_autocmd('LspAttach', {
desc = 'LSP actions', -- desc = 'LSP actions',
callback = function() -- callback = function()
local bufmap = function(mode, lhs, rhs) -- local bufmap = function(mode, lhs, rhs)
local opts = {buffer = true} -- local opts = {buffer = true}
vim.keymap.set(mode, lhs, rhs, opts) -- vim.keymap.set(mode, lhs, rhs, opts)
end -- end
--
-- Displays hover information about the symbol under the cursor -- -- Displays hover information about the symbol under the cursor
bufmap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>') -- bufmap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>')
--
-- Jump to the definition -- -- Jump to the definition
bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>') -- bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>')
--
-- Jump to declaration -- -- Jump to declaration
bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>') -- bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
--
-- Lists all the implementations for the symbol under the cursor -- -- Lists all the implementations for the symbol under the cursor
bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>') -- bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>')
--
-- Jumps to the definition of the type symbol -- -- Jumps to the definition of the type symbol
bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>') -- bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
--
-- Lists all the references -- -- Lists all the references
bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>') -- bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>')
--
-- Displays a function's signature information -- -- Displays a function's signature information
bufmap('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>') -- bufmap('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
--
-- Renames all references to the symbol under the cursor -- -- Renames all references to the symbol under the cursor
bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>') -- bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>')
--
-- Selects a code action available at the current cursor position -- -- Selects a code action available at the current cursor position
bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>') -- bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>')
--
-- Show diagnostics in a floating window -- -- Show diagnostics in a floating window
bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>') -- bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
--
-- Move to the previous diagnostic -- -- Move to the previous diagnostic
bufmap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>') -- bufmap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
--
-- Move to the next diagnostic -- -- Move to the next diagnostic
bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>') -- bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
end -- end
}) -- })
--

View File

@ -1,73 +0,0 @@
return {
{"nvim-treesitter/nvim-treesitter"},
{'numToStr/Comment.nvim',
opts = {
-- add any options here
},
lazy = false,
},
{"rose-pine/neovim", name = "rose-pine"},
{ "ellisonleao/gruvbox.nvim", priority = 1000 , config = true, opts = ...},
{"nvim-lualine/lualine.nvim", dependencies = {
"nvim-tree/nvim-web-devicons",
}
},
{"folke/zen-mode.nvim",
opts = {
window = {width = 60}}
},
{"folke/twilight.nvim", opts = {context = 1}},
{"preservim/vim-pencil"},
{"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
}
},
{'akinsho/bufferline.nvim', version = "*", dependencies = 'nvim-tree/nvim-web-devicons'},
{"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
},
--##################################################
--## LANGUAGE SERVER CONFIGS
--##################################################
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
--#################################################
--## AUTOCOMPLETION/SNIPPETS
--#################################################
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
{"L3MON4D3/LuaSnip",
-- follow latest release.
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
-- install jsregexp (optional!).
build = "make install_jsregexp",
dependencies = { "rafamadriz/friendly-snippets" },
},
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
---#####################################################################
---## LINTING
---#####################################################################
"mfussenegger/nvim-lint",
"WhoIsSethDaniel/toggle-lsp-diagnostics.nvim"
}

View File

@ -0,0 +1,8 @@
return {
"akinsho/bufferline.nvim",
version = "*",
dependencies = "nvim-tree/nvim-web-devicons",
config = function()
require("bufferline").setup({})
end,
}

6
lua/plugins/comment.lua Normal file
View File

@ -0,0 +1,6 @@
return {'numToStr/Comment.nvim',
opts = {
-- add any options here
},
lazy = false,
}

106
lua/plugins/completion.lua Normal file
View File

@ -0,0 +1,106 @@
return {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
{
"L3MON4D3/LuaSnip",
-- follow latest release.
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
-- install jsregexp (optional!).
build = "make install_jsregexp",
dependencies = { "rafamadriz/friendly-snippets" },
},
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
{
"hrsh7th/nvim-cmp",
config = function()
vim.opt.completeopt = { "menu", "menuone", "noselect" }
local cmp = require("cmp")
local luasnip = require("luasnip")
local select_opts = { behavior = cmp.SelectBehavior.Select }
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
sources = {
{ name = "path" },
{ name = "nvim_lsp", keyword_length = 1 },
{ name = "buffer", keyword_length = 3 },
{ name = "luasnip", keyword_length = 2 },
},
window = {
documentation = cmp.config.window.bordered(),
},
formatting = {
fields = { "menu", "abbr", "kind" },
format = function(entry, item)
local menu_icon = {
nvim_lsp = "λ",
luasnip = "",
buffer = "Ω",
path = "🖫",
}
item.menu = menu_icon[entry.source.name]
return item
end,
},
mapping = {
["<Up>"] = cmp.mapping.select_prev_item(select_opts),
["<Down>"] = cmp.mapping.select_next_item(select_opts),
["<C-p>"] = cmp.mapping.select_prev_item(select_opts),
["<C-n>"] = cmp.mapping.select_next_item(select_opts),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-e>"] = cmp.mapping.abort(),
["<C-y>"] = cmp.mapping.confirm({ select = true }),
["<CR>"] = cmp.mapping.confirm({ select = false }),
["<C-f>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
["<C-b>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
["<Tab>"] = cmp.mapping(function(fallback)
local col = vim.fn.col(".") - 1
if cmp.visible() then
cmp.select_next_item(select_opts)
elseif col == 0 or vim.fn.getline("."):sub(col, col):match("%s") then
fallback()
else
cmp.complete()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item(select_opts)
else
fallback()
end
end, { "i", "s" }),
},
})
end,
},
}

View File

@ -0,0 +1,38 @@
return {
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function()
local conform = require("conform")
conform.setup({
formatters_by_ft = {
javascript = { "prettier" },
typescript = { "prettier" },
javascriptreact = { "prettier" },
typescriptreact = { "prettier" },
svelte = { "prettier" },
css = { "prettier" },
html = { "prettier" },
json = { "prettier" },
yaml = { "prettier" },
markdown = { "prettier" },
graphql = { "prettier" },
lua = { "stylua" },
python = { "isort", "black" },
},
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 500,
},
})
vim.keymap.set({ "n", "v" }, "<leader>mp", function()
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 500,
})
end, { desc = "Format file or range (in visual mode)" })
end,
}

16
lua/plugins/lazygit.lua Normal file
View File

@ -0,0 +1,16 @@
return {
{
"kdheepak/lazygit.nvim",
cmd = {
"LazyGit",
"LazyGitConfig",
"LazyGitCurrentFile",
"LazyGitFilter",
"LazyGitFilterCurrentFile",
},
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
},
},
}

43
lua/plugins/linting.lua Normal file
View File

@ -0,0 +1,43 @@
return {
{
"mfussenegger/nvim-lint",
event = {
"BufReadPre",
"BufNewFile",
},
config = function()
local lint = require("lint")
lint.linters_by_ft = {
javascript = { "eslint_d" },
typescript = { "eslint_d" },
javascriptreact = { "eslint_d" },
typescriptreact = { "eslint_d" },
svelte = { "eslint_d" },
python = { "pylint" },
markdown = { "proselint" },
}
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
lint.try_lint()
end,
})
vim.keymap.set("n", "<leader>l", function()
lint.try_lint()
end, { desc = "Trigger linting for current file" })
end,
},
{
"WhoIsSethDaniel/toggle-lsp-diagnostics.nvim",
config = function()
require("toggle_lsp_diagnostics").init({
start_on = false,
})
end,
},
}

View File

@ -1,9 +1,8 @@
return {"neovim/nvim-lspconfig",
config = function()
local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities() local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities()
local lspconfig = require('lspconfig') local lspconfig = require('lspconfig')
require("mason").setup()
require("mason-lspconfig").setup {
-- ensure_installed = { "lua_ls", "grammarly", "ltex" },
}
lspconfig.lua_ls.setup { lspconfig.lua_ls.setup {
capabilities = lsp_capabilities, capabilities = lsp_capabilities,
settings = { settings = {
@ -27,6 +26,10 @@ lspconfig.lua_ls.setup {
-- return require'lspconfig'.util.find_git_ancestor(fname) or vim.loop.os_homedir() -- return require'lspconfig'.util.find_git_ancestor(fname) or vim.loop.os_homedir()
-- end, -- end,
-- } -- }
-- require("lspconfig").marksman.setup { -- lspconfig.marksman.setup {
-- capabilities = lsp_capabilities, -- capabilities = lsp_capabilities,
-- } -- }
end
}

41
lua/plugins/lsp/mason.lua Normal file
View File

@ -0,0 +1,41 @@
return {
{
"williamboman/mason.nvim",
dependencies = { "WhoIsSethDaniel/mason-tool-installer.nvim" },
config = function()
-- import mason
local mason = require("mason")
local mason_tool_installer = require("mason-tool-installer")
-- enable mason and configure icons
mason.setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
})
mason_tool_installer.setup({
ensure_installed = {
"prettier", -- prettier formatter
"stylua", -- lua formatter
"isort", -- python formatter
"black", -- python formatter
"pylint", -- python linter
"eslint_d", -- js linter
},
})
end,
},
-- {"williamboman/mason-lspconfig.nvim",
-- config = function()
-- local mason_lspconfig = require("mason-lspconfig")
-- mason_lspconfig.setup {
-- ensure_installed = { "grammarly", "ltex" },
-- }
-- end
-- }
}

16
lua/plugins/lualine.lua Normal file
View File

@ -0,0 +1,16 @@
return {
"nvim-lualine/lualine.nvim",
dependencies = {
"nvim-tree/nvim-web-devicons",
},
config = function()
local function getWords()
return tostring(vim.fn.wordcount().words)
end
require("lualine").setup({
sections = {
lualine_z = { getWords },
},
})
end,
}

9
lua/plugins/neotree.lua Normal file
View File

@ -0,0 +1,9 @@
return {"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
}
}

View File

@ -0,0 +1 @@
return { "ellisonleao/gruvbox.nvim", priority = 1000 , config = true, opts = ...}

View File

@ -0,0 +1,2 @@
return {"rose-pine/neovim", name = "rose-pine"}

View File

@ -0,0 +1,3 @@
return {
"nvim-treesitter/nvim-treesitter"
}

1
lua/plugins/twilight.lua Normal file
View File

@ -0,0 +1 @@
return {"folke/twilight.nvim", opts = {context = 1}}

View File

@ -0,0 +1 @@
return {"preservim/vim-pencil"}

12
lua/plugins/which-key.lua Normal file
View File

@ -0,0 +1,12 @@
return {"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
}

4
lua/plugins/zen-mode.lua Normal file
View File

@ -0,0 +1,4 @@
return {"folke/zen-mode.nvim",
opts = {
window = {width = 60}}
}

View File

@ -1 +0,0 @@
require("bufferline").setup{}

View File

@ -1,8 +0,0 @@
local function getWords()
return tostring(vim.fn.wordcount().words)
end
require('lualine').setup {
sections = {
lualine_z = { getWords },
},
}

View File

@ -1,2 +0,0 @@
require("neo-tree").setup({})

View File

@ -1,85 +0,0 @@
vim.opt.completeopt = {'menu', 'menuone', 'noselect'}
local cmp = require('cmp')
local luasnip = require('luasnip')
local select_opts = {behavior = cmp.SelectBehavior.Select}
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end
},
sources = {
{name = 'path'},
{name = 'nvim_lsp', keyword_length = 1},
{name = 'buffer', keyword_length = 3},
{name = 'luasnip', keyword_length = 2},
},
window = {
documentation = cmp.config.window.bordered()
},
formatting = {
fields = {'menu', 'abbr', 'kind'},
format = function(entry, item)
local menu_icon = {
nvim_lsp = 'λ',
luasnip = '',
buffer = 'Ω',
path = '🖫',
}
item.menu = menu_icon[entry.source.name]
return item
end,
},
mapping = {
['<Up>'] = cmp.mapping.select_prev_item(select_opts),
['<Down>'] = cmp.mapping.select_next_item(select_opts),
['<C-p>'] = cmp.mapping.select_prev_item(select_opts),
['<C-n>'] = cmp.mapping.select_next_item(select_opts),
['<C-u>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),
['<C-e>'] = cmp.mapping.abort(),
['<C-y>'] = cmp.mapping.confirm({select = true}),
['<CR>'] = cmp.mapping.confirm({select = false}),
['<C-f>'] = cmp.mapping(function(fallback)
if luasnip.jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, {'i', 's'}),
['<C-b>'] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, {'i', 's'}),
['<Tab>'] = cmp.mapping(function(fallback)
local col = vim.fn.col('.') - 1
if cmp.visible() then
cmp.select_next_item(select_opts)
elseif col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
fallback()
else
cmp.complete()
end
end, {'i', 's'}),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item(select_opts)
else
fallback()
end
end, {'i', 's'}),
},
})

View File

@ -1,9 +0,0 @@
require('lint').linters_by_ft = {
markdown = {'proselint',}
}
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
callback = function()
require("lint").try_lint()
end,
})

View File

@ -1,3 +0,0 @@
require('toggle_lsp_diagnostics').init({
start_on = false,
})

Binary file not shown.

Binary file not shown.

Binary file not shown.