mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 08:41:43 +05:30
NVIM Auto Completion
- Achieved using none-ls & nvim-cmp - ugly and unintuitive
This commit is contained in:
8
common/.config/nvim/lua/plugins/coding-debugging.lua
Normal file
8
common/.config/nvim/lua/plugins/coding-debugging.lua
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"folke/trouble.nvim",
|
||||||
|
config = function ()
|
||||||
|
require("trouble").setup({})
|
||||||
|
end
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -11,9 +11,9 @@ return {
|
|||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
keymaps = {
|
keymaps = {
|
||||||
init_selection = "<C-space>",
|
init_selection = "<C-A-space>",
|
||||||
node_incremental = "<C-space>",
|
node_incremental = "<C-A-space>",
|
||||||
scope_incremental = "<C-CR>",
|
scope_incremental = "<C-A-CR>",
|
||||||
node_decremental = "<bs>",
|
node_decremental = "<bs>",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,9 @@ return {
|
|||||||
"lukas-reineke/indent-blankline.nvim",
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
main = "ibl",
|
main = "ibl",
|
||||||
config = function()
|
config = function()
|
||||||
require("ibl").setup({})
|
require("ibl").setup({
|
||||||
|
indent = { char = "┆" },
|
||||||
|
})
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
-- { "windwp/nvim-autopairs" },
|
-- { "windwp/nvim-autopairs" },
|
||||||
@@ -36,5 +38,3 @@ return {
|
|||||||
-- end
|
-- end
|
||||||
-- },
|
-- },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,30 @@
|
|||||||
return {
|
-- TODO: Autocompletion is a hit and miss. Way too complicated at this point
|
||||||
-- TODO: Configure following plugins in separate files
|
-- TODO: Try doing LazyVim.nvim instead
|
||||||
|
|
||||||
|
return {
|
||||||
-- LSP Configuration
|
-- LSP Configuration
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
lazy = false,
|
||||||
|
config = function()
|
||||||
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||||
|
|
||||||
|
local lspconfig = require("lspconfig")
|
||||||
|
lspconfig.tsserver.setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
|
lspconfig.html.setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
|
lspconfig.lua_ls.setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
},
|
||||||
{
|
{
|
||||||
-- Provides :Mason command which installs Language Servers
|
-- Provides :Mason command which installs Language Servers
|
||||||
"williamboman/mason.nvim",
|
"williamboman/mason.nvim",
|
||||||
|
lazy = false,
|
||||||
config = function()
|
config = function()
|
||||||
require("mason").setup()
|
require("mason").setup()
|
||||||
end
|
end
|
||||||
@@ -12,105 +32,117 @@ return {
|
|||||||
{
|
{
|
||||||
-- Helps to auto install Language Servers by specifying them
|
-- Helps to auto install Language Servers by specifying them
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"williamboman/mason-lspconfig.nvim",
|
||||||
|
lazy = false,
|
||||||
|
opts = {
|
||||||
|
auto_install = true,
|
||||||
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require("mason-lspconfig").setup({
|
require("mason-lspconfig").setup({})
|
||||||
ensure_installed = {
|
end
|
||||||
"lua_ls", "bashls", "cssls", "dockerls", "emmet_ls", "jsonls", "tsserver", "marksman",
|
},
|
||||||
"pyre", "rust_analyzer", "sqlls", "taplo"
|
{
|
||||||
}
|
"hrsh7th/nvim-cmp",
|
||||||
|
lazy = false,
|
||||||
|
config = function()
|
||||||
|
local cmp = require("cmp")
|
||||||
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
window = {
|
||||||
|
documentation = cmp.config.window.bordered(),
|
||||||
|
completion = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
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(),
|
||||||
|
["<C-e>"] = cmp.mapping.abort(),
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources(
|
||||||
|
{
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
{ name = "luasnip" },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ name = "buffer" },
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"neovim/nvim-lspconfig",
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
config = function()
|
lazy = false,
|
||||||
-- Hook up NVIM with the above installed Language Servers
|
config = true,
|
||||||
local lspconfig = require("lspconfig")
|
|
||||||
lspconfig.lua_ls.setup({})
|
|
||||||
lspconfig.bashls.setup({})
|
|
||||||
lspconfig.cssls.setup({})
|
|
||||||
lspconfig.dockerls.setup({})
|
|
||||||
lspconfig.emmet_ls.setup({})
|
|
||||||
lspconfig.jsonls.setup({})
|
|
||||||
lspconfig.tsserver.setup({})
|
|
||||||
lspconfig.marksman.setup({})
|
|
||||||
lspconfig.pyre.setup({})
|
|
||||||
lspconfig.rust_analyzer.setup({})
|
|
||||||
lspconfig.sqlls.setup({})
|
|
||||||
lspconfig.taplo.setup({})
|
|
||||||
|
|
||||||
-- LSP Keybindings
|
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
|
||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
|
||||||
vim.keymap.set({ 'n', 'v' }, '<leader>ca', vim.lsp.buf.code_action, {})
|
|
||||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist)
|
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, {})
|
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {})
|
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, {})
|
|
||||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, {})
|
|
||||||
-- vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, {})
|
|
||||||
vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, {})
|
|
||||||
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, {})
|
|
||||||
vim.keymap.set('n', '<leader>wl', function()
|
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
||||||
end, {})
|
|
||||||
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, {})
|
|
||||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, {})
|
|
||||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, {})
|
|
||||||
vim.keymap.set('n', '<leader>f', function()
|
|
||||||
vim.lsp.buf.format { async = true }
|
|
||||||
end, {})
|
|
||||||
end
|
|
||||||
},
|
},
|
||||||
|
|
||||||
-- None-ls
|
|
||||||
{
|
{
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
version = "v2.*",
|
||||||
|
lazy = false,
|
||||||
|
dependencies = {
|
||||||
|
"rafamadriz/friendly-snippets",
|
||||||
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
-- Injects LSP's diagnostics, code actions & formatting
|
||||||
|
-- None-ls provides methods to add none-LSP sources to provide hooks to NeoVim
|
||||||
|
-- It also provides helpers to start and capture output of LS-CLI applications
|
||||||
"nvimtools/none-ls.nvim",
|
"nvimtools/none-ls.nvim",
|
||||||
|
dependencies = { "nvim-lua/plenary.nvim" },
|
||||||
config = function()
|
config = function()
|
||||||
local null_ls = require("null-ls")
|
local null_ls = require("null-ls")
|
||||||
|
|
||||||
null_ls.setup({
|
null_ls.setup({
|
||||||
sources = {
|
sources = {
|
||||||
-- TODO: Segement these by language & Install required ones through :Mason
|
-- Hover
|
||||||
-- null_ls.builtins.formatting.stylua,
|
null_ls.builtins.hover.dictionary,
|
||||||
-- null_ls.builtins.formatting.beautysh,
|
|
||||||
-- null_ls.builtins.formatting.csharpier,
|
|
||||||
-- null_ls.builtins.formatting.jq,
|
|
||||||
-- null_ls.builtins.formatting.markdownlint_toc,
|
|
||||||
-- null_ls.builtins.formatting.nginx_beautifier,
|
|
||||||
-- null_ls.builtins.formatting.pg_format,
|
|
||||||
-- null_ls.builtins.formatting.prettierd,
|
|
||||||
-- null_ls.builtins.formatting.protolint,
|
|
||||||
-- null_ls.builtins.formatting.rustfmt,
|
|
||||||
-- null_ls.builtins.formatting.shellharden,
|
|
||||||
-- null_ls.builtins.formatting.shfmt,
|
|
||||||
|
|
||||||
-- null_ls.builtins.diagnostics.alex,
|
-- Code Actions
|
||||||
-- null_ls.builtins.diagnostics.codespell,
|
null_ls.builtins.code_actions.eslint_d,
|
||||||
-- null_ls.builtins.diagnostics.eslint_d,
|
null_ls.builtins.code_actions.refactoring,
|
||||||
-- null_ls.builtins.diagnostics.jsonlint,
|
null_ls.builtins.code_actions.shellcheck,
|
||||||
-- null_ls.builtins.diagnostics.luacheck,
|
|
||||||
-- null_ls.builtins.diagnostics.protolint,
|
|
||||||
-- null_ls.builtins.diagnostics.shellcheck,
|
|
||||||
-- null_ls.builtins.diagnostics.stylelint,
|
|
||||||
-- null_ls.builtins.diagnostics.tidy,
|
|
||||||
-- null_ls.builtins.diagnostics.tsc,
|
|
||||||
-- null_ls.builtins.diagnostics.vlint,
|
|
||||||
-- null_ls.builtins.diagnostics.yamllint,
|
|
||||||
|
|
||||||
-- null_ls.builtins.code_actions.gitsigns,
|
-- Formattings
|
||||||
-- null_ls.builtins.code_actions.eslint_d,
|
null_ls.builtins.formatting.prettierd,
|
||||||
-- null_ls.builtins.code_actions.refactoring,
|
null_ls.builtins.formatting.beautysh,
|
||||||
-- null_ls.builtins.code_actions.shellcheck,
|
null_ls.builtins.formatting.buf,
|
||||||
|
null_ls.builtins.formatting.cs,
|
||||||
|
null_ls.builtins.formatting.jq,
|
||||||
|
null_ls.builtins.formatting.rustfmt,
|
||||||
|
|
||||||
-- null_ls.builtins.completion.spell,
|
-- Completions
|
||||||
-- null_ls.builtins.completion.tags,
|
null_ls.builtins.completion.luasnip,
|
||||||
-- null_ls.builtins.completion.luasnip,
|
null_ls.builtins.completion.spell,
|
||||||
|
|
||||||
|
-- Diagnostics
|
||||||
|
null_ls.builtins.diagnostics.buf,
|
||||||
|
null_ls.builtins.diagnostics.eslint_d,
|
||||||
|
null_ls.builtins.diagnostics.jsonlint,
|
||||||
|
null_ls.builtins.diagnostics.luacheck,
|
||||||
|
null_ls.builtins.diagnostics.markdownlint,
|
||||||
|
null_ls.builtins.diagnostics.shellcheck,
|
||||||
|
null_ls.builtins.diagnostics.stylelint,
|
||||||
|
null_ls.builtins.diagnostics.tsc,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>gf", vim.lsp.buf.format, {})
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, {})
|
||||||
|
vim.keymap.set("n", "<leader>gd", vim.lsp.buf.definition, {})
|
||||||
|
vim.keymap.set("n", "<leader>gr", vim.lsp.buf.references, {})
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>rr", vim.lsp.buf.rename, {})
|
||||||
|
vim.keymap.set("n", "<leader>df", vim.lsp.buf.format, {})
|
||||||
|
|
||||||
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
||||||
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
||||||
|
vim.keymap.set("n", "<leader>da", vim.lsp.buf.code_action, {})
|
||||||
|
vim.keymap.set('n', '<leader>do', vim.diagnostic.open_float)
|
||||||
|
vim.keymap.set('n', '<leader>dq', vim.diagnostic.setloclist)
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
5
common/.config/nvim/lua/plugins/coding-others.lua
Normal file
5
common/.config/nvim/lua/plugins/coding-others.lua
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"theprimeagen/refactoring.nvim"
|
||||||
|
},
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user