End of config for now

This commit is contained in:
2023-12-30 18:35:52 +01:00
parent c6fc077654
commit 9d87a5985d
21 changed files with 490 additions and 131 deletions

View File

@@ -6,20 +6,27 @@
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "ad2b5ecd907128ed1b66b1cf4bed57902ef836ee" },
"friendly-snippets": { "branch": "main", "commit": "53d3df271d031c405255e99410628c26a8f0d2b0" },
"gitsigns.nvim": { "branch": "main", "commit": "d195f0c35ced5174d3ecce1c4c8ebb3b5bc23fa9" },
"indent-blankline.nvim": { "branch": "master", "commit": "5da5546947f3125dfd6aa85ab21074dc83f776d5" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"lspkind.nvim": { "branch": "master", "commit": "7f26cf5e27e2bd910ce0ea00c514da2bf97423b8" },
"lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "8b70e7f1e0a4119c1234c3bde4a01c241cabcc74" },
"mason.nvim": { "branch": "main", "commit": "a09da6ac634926a299dd439da08bdb547a8ca011" },
"nvim-autopairs": { "branch": "master", "commit": "9fd41181693dd4106b3e414a822bb6569924de81" },
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
"nvim-tree.lua": { "branch": "master", "commit": "50f30bcd8c62ac4a83d133d738f268279f2c2ce2" },
"nvim-treesitter": { "branch": "master", "commit": "7d0b4756aba3b220d38ec0443c6cc10944060dd7" },
"nvim-web-devicons": { "branch": "master", "commit": "43aa2ddf476012a2155f5f969ee55ab17174da7a" },
"nvim-lint": { "branch": "master", "commit": "3ffa176628fe49e74f47992757016b7371a9b86b" },
"nvim-lspconfig": { "branch": "master", "commit": "0d9e870d01894c592d7ea93cfe0fa451916d9a7f" },
"nvim-tree.lua": { "branch": "master", "commit": "96a783fbd606a458bcce2ef8041240a8b94510ce" },
"nvim-treesitter": { "branch": "master", "commit": "e49f1e8ef3e8450a8446cb1f2bbb53c919f60b6d" },
"nvim-web-devicons": { "branch": "master", "commit": "808627b8d412b2a6b6fc6eed816fec3557198b01" },
"onedark.nvim": { "branch": "master", "commit": "c5476a091b0f1b4e853db91c91ff941f848a1cdd" },
"plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "a249476e451673f7811852d93109dff19311ee39" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
"telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
}

View File

@@ -5,7 +5,7 @@ if not ok then
end
--- Plugin options
opts = {
local opts = {
options = {
-- mode = "tabs",
separator_style = "slant",

View File

@@ -11,3 +11,8 @@ require("config/rainbow-delimiters")
require("config/telescope")
require("config/which-key")
require("config/nvim-cmp")
require("config/mason")
require("config/lsp/signs")
require("config/lsp/bash")
require("config/lsp/lua")
require("config/lsp/web")

43
lua/config/lsp/attach.lua Normal file
View File

@@ -0,0 +1,43 @@
return function()
local km = vim.keymap.set
local opts = {}
opts.desc = "show documentation under cursor"
km("n", "<leader>lK", vim.lsp.buf.hover, opts)
opts.desc = "show LSP References"
km("n", "<leader>lR", ":Telescope lsp_references<cr>", opts)
opts.desc = "go to declaration"
km("n", "<leader>lD", "vim.lsp.buf.declaration<cr>", opts)
opts.desc = "show LSP definition"
km("n", "<leader>ld", ":Telescope lsp_definitions<cr>", opts)
opts.desc = "Show LSP implementations"
km("n", "<leader>li", ":Telescope lsp_implementations<cr>", opts)
opts.desc = "Show LSP type definitions"
km("n", "<leader>lt", ":Telescope lsp_type_definitions<cr>", opts)
opts.desc = "See available code actions"
km({ "n", "v" }, "<leader>lc", vim.lsp.buf.code_action, opts)
opts.desc = "Smart rename"
km("n", "<leader>ln", vim.lsp.buf.rename, opts)
opts.desc = "Show buffer diagnostics"
km("n", "<leader>lE", ":Telescope diagnostics bufnr=0<cr>", opts)
opts.desc = "Show line diagnostics"
km("n", "<leader>le", vim.diagnostic.open_float, opts)
opts.desc = "Go to previous diagnostic"
km("n", "<leader>lp", vim.diagnostic.goto_prev, opts)
opts.desc = "Go to next diagnostic"
km("n", "<leader>ln", vim.diagnostic.goto_next, opts)
opts.desc = "Restart LSP"
km("n", "<leader>ls", ":LspRestart<cr>", opts)
end

57
lua/config/lsp/bash.lua Normal file
View File

@@ -0,0 +1,57 @@
local ok, mason_lspconfig, mason_tool_installer, lspconfig, conform, lint = pcall(function()
return require("mason-lspconfig"),
require("mason-tool-installer"),
require("lspconfig"),
require("conform"),
require("lint")
end)
if not ok then
return
end
mason_lspconfig.setup({
ensure_installed = { "bashls" },
})
lspconfig.bashls.setup({
capabilities = require("config/lsp/capabilities"),
on_attach = require("config/lsp/attach"),
})
mason_tool_installer.setup({
ensure_installed = { "shellcheck" },
})
conform.setup({
formatters_by_ft = {
sh = { "shellcheck" },
},
format_on_save = {
async = false,
timeout_ms = 500,
lsp_fallback = true,
},
})
vim.keymap.set({ "n", "v" }, "<leader>lf", function()
conform.format({
async = false,
timeout_ms = 500,
lsp_fallback = true,
})
end, { desc = "Format" })
lint.linters_by_ft = {
lua = { "shellcheck" },
}
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
callback = function()
lint.try_lint()
end,
})
vim.keymap.set("n", "<leader>ll", function()
lint.try_lint()
end, { desc = "Lint" })

View File

@@ -0,0 +1,6 @@
local ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not ok then
return
end
return cmp_nvim_lsp.default_capabilities()

73
lua/config/lsp/lua.lua Normal file
View File

@@ -0,0 +1,73 @@
local ok, mason_lspconfig, mason_tool_installer, lspconfig, conform, lint = pcall(function()
return require("mason-lspconfig"),
require("mason-tool-installer"),
require("lspconfig"),
require("conform"),
require("lint")
end)
if not ok then
return
end
mason_lspconfig.setup({
ensure_installed = { "lua_ls" },
})
mason_tool_installer.setup({
ensure_installed = { "stylua", "luacheck" },
})
lspconfig.lua_ls.setup({
-- capabilities = cmp_nvim_lsp.default_capabilities()
capabilities = require("config/lsp/capabilities"),
on_attach = require("config/lsp/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,
},
},
},
},
})
conform.setup({
formatters_by_ft = {
lua = { "stylua" },
},
format_on_save = {
async = false,
timeout_ms = 500,
lsp_fallback = true,
},
})
vim.keymap.set({ "n", "v" }, "<leader>lf", function()
conform.format({
async = false,
timeout_ms = 500,
lsp_fallback = true,
})
end, { desc = "Format" })
lint.linters_by_ft = {
lua = { "luacheck" },
}
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
callback = function()
lint.try_lint()
end,
})
vim.keymap.set("n", "<leader>ll", function()
lint.try_lint()
end, { desc = "Lint" })

6
lua/config/lsp/signs.lua Normal file
View File

@@ -0,0 +1,6 @@
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

83
lua/config/lsp/web.lua Normal file
View File

@@ -0,0 +1,83 @@
local ok, mason_lspconfig, mason_tool_installer, lspconfig, conform, lint = pcall(function()
return require("mason-lspconfig"),
require("mason-tool-installer"),
require("lspconfig"),
require("conform"),
require("lint")
end)
if not ok then
return
end
mason_lspconfig.setup({
ensure_installed = {
"tsserver",
"html",
"emmet_ls",
"cssls",
},
})
lspconfig.tsserver.setup({
capabilities = require("config/lsp/capabilities"),
on_attach = require("config/lsp/attach"),
})
lspconfig.html.setup({
capabilities = require("config/lsp/capabilities"),
on_attach = require("config/lsp/attach"),
})
lspconfig.emmet_ls.setup({
capabilities = require("config/lsp/capabilities"),
on_attach = require("config/lsp/attach"),
})
lspconfig.cssls.setup({
capabilities = require("config/lsp/capabilities"),
on_attach = require("config/lsp/attach"),
})
mason_tool_installer.setup({
ensure_installed = {
"prettierd",
"prettier",
"eslint_d",
},
})
conform.setup({
formatters_by_ft = {
javascript = { { "prettierd", "prettier" } },
json = { { "prettierd", "prettier" } },
},
format_on_save = {
async = false,
timeout_ms = 500,
lsp_fallback = true,
},
})
vim.keymap.set({ "n", "v" }, "<leader>lf", function()
conform.format({
async = false,
timeout_ms = 500,
lsp_fallback = true,
})
end, { desc = "Format" })
lint.linters_by_ft = {
javascript = { "eslint_d" },
json = { "eslint_d" },
}
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
callback = function()
lint.try_lint()
end,
})
vim.keymap.set("n", "<leader>ll", function()
lint.try_lint()
end, { desc = "Lint" })

View File

@@ -7,7 +7,7 @@ if not ok then
end
--- Plugin options
opts = {
local opts = {
options = {
theme = "onedark",
},

19
lua/config/mason.lua Normal file
View File

@@ -0,0 +1,19 @@
--- Ensure plugin is installed
local ok, mason = pcall(require, "mason")
if not ok then
return
end
--- Plugin options
local opts = {
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
}
--- Load plugin
mason.setup(opts)

View File

@@ -1,8 +1,6 @@
--- Ensure plugins are installed
local ok, cmp, luasnip, lspkind = pcall(function()
return require("cmp"),
require("luasnip"),
require("lspkind")
return require("cmp"), require("luasnip"), require("lspkind")
end)
if not ok then
@@ -12,7 +10,7 @@ end
--- loads vscode style snippets from installed plugins (e.g. friendly-snippets)
require("luasnip.loaders.from_vscode").lazy_load()
opts = {
local opts = {
completion = {
completeopt = "menu,menuone,preview,noselect",
},
@@ -39,5 +37,7 @@ opts = {
maxwidth = 50,
ellipsis_char = "...",
}),
},v
},
}
cmp.setup(opts)

View File

@@ -33,6 +33,9 @@ local opts = {
filters = {
dotfiles = false,
},
diagnostics = {
enable = true,
},
}
--- Load plugin
@@ -40,8 +43,8 @@ nvimtree.setup(opts)
--- Override keymap
local km = vim.keymap.set
km('n', '<C-e>', ':NvimTreeFocus<cr>')
km('n', '<leader>ee', ':NvimTreeToggle<cr>')
km('n', '<leader>ef', ':NvimTreeFindFileToggle<cr>')
km('n', '<leader>ec', ':NvimTreeCollapse<cr>')
km('n', '<leader>er', ':NvimTreeRefresh<cr>')
km("n", "<C-e>", ":NvimTreeFocus<cr>")
km("n", "<leader>ee", ":NvimTreeToggle<cr>")
km("n", "<leader>ef", ":NvimTreeFindFileToggle<cr>")
km("n", "<leader>ec", ":NvimTreeCollapse<cr>")
km("n", "<leader>er", ":NvimTreeRefresh<cr>")

View File

@@ -5,7 +5,7 @@ if not ok then
end
--- Plugin options
opts = {
local opts = {
highlight = {
enable = true,
},

View File

@@ -19,10 +19,10 @@ vim.g.rainbow_delimiters = {
highlight = {
'RainbowDelimiterYellow',
'RainbowDelimiterBlue',
'RainbowDelimiterOrange',
'RainbowDelimiterGreen',
-- 'RainbowDelimiterGreen',
'RainbowDelimiterViolet',
'RainbowDelimiterCyan',
-- 'RainbowDelimiterCyan',
-- 'RainbowDelimiterOrange',
'RainbowDelimiterRed',
},
}

View File

@@ -1,12 +1,33 @@
--- Ensute telescope is installed
local ok, telescope = pcall(require, "telescope.builtin")
local ok, telescope, builtin = pcall(function()
return require("telescope"), require("telescope.builtin")
end)
if not ok then
return
end
--- Pluggin options
local opts = {
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown({}),
},
},
}
--- Load pluggin
telescope.setup(opts)
telescope.load_extension("ui-select")
--- Override keymaps
opts = {}
local km = vim.keymap.set
km("n", "<leader>ff", telescope.find_files, {desc = "find files"})
km("n", "<leader>fg", telescope.live_grep, {desc = "live grep"})
km("n", "<leader>fb", telescope.buffers, {desc = "buffers"})
km("n", "<leader>fh", telescope.help_tags, {desc = "help tags"})
opts.desc = "find files"
km("n", "<leader>ff", builtin.find_files, opts)
opts.desc = "live grep"
km("n", "<leader>fg", builtin.live_grep, opts)
opts.desc = "buffers"
km("n", "<leader>fb", builtin.buffers, opts)
opts.desc = "help tags"
km("n", "<leader>fh", builtin.help_tags, opts)

View File

@@ -17,10 +17,22 @@ wichkey.register({
name = "NvimTree",
},
f = {
name = "Telescope"
name = "Telescope",
},
l = {
name = "Lsp",
},
s = {
name = "Treesitter",
},
b = {
name = "Bufferline",
},
t = {
name = "Table",
},
}, { prefix = "<leader>" })
--- Override keymap
local km = vim.keymap.set
km('n', '<C-s>', ':WhichKey<cr>', { desc = "Which-key" })
km("n", "<C-s>", ":WhichKey<cr>", { desc = "Which-key" })

View File

@@ -1,2 +1 @@
require("core.keymap")
require("core.options")

View File

21
lua/plugins/mason.lua Normal file
View File

@@ -0,0 +1,21 @@
return {
"williamboman/mason.nvim",
dependencies = {
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
{
"neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
{
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
},
{
"mfussenegger/nvim-lint",
event = { "BufReadPre", "BufNewFile" },
},
},
},
},
}

View File

@@ -1,4 +1,8 @@
return {
'nvim-telescope/telescope.nvim', tag = '0.1.5',
dependencies = { 'nvim-lua/plenary.nvim' },
"nvim-telescope/telescope.nvim",
tag = "0.1.5",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope-ui-select.nvim",
},
}