Table of Contents
- Mini Animate
- JSON
- Markdown Preview
- Config Java (JDTLS)
- Auto Save
- Override Lualine
- Config Neotree
- Overide Bufferline
- Typescript (jose-elias-alvarez)
- Denols (deno-nvim)
- clangd (clangd_extensions.nvim)
- Config Flutter Tool
- Config rust-tools
- Rekomendasi Colorscheme
- symbols-outline.nvim
- trouble.nvim
- Mini Indentscope
- yanky.nvim
- Code Runner
- todo-comments.nvim
- Neoscroll
- Laravel Nvim
- CMP Cmdline
- nvim-treesitter-context
- Golang Setup
- Color Scheme Github Dark Nvim
- Color Scheme OnedarkPro
- Codeium
- Code Window
- LSP Line
- MiniMap 2
- Overide Lualine
- Custom Lueline Dracula Theme
- Nvim-Ufo
- tailwindcss-colorizer-cmp.nvim
- Telescope File Browser
- Refactoring
- Database Management
- Neotest-Jest
- Debuging Javascript
- Conformm Config
- Custem Config Nvim-lint
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Mini Animate
- Create file lua/plugin/mini_animate.lua
- Fill the code like this
return {
-- animations
{
"echasnovski/mini.animate",
event = "VeryLazy",
opts = function()
-- don't use animate when scrolling with the mouse
local mouse_scrolled = false
for _, scroll in ipairs({ "Up", "Down" }) do
local key = "<ScrollWheel" .. scroll .. ">"
vim.keymap.set({ "", "i" }, key, function()
mouse_scrolled = true
return key
end, { expr = true })
end
local animate = require("mini.animate")
return {
resize = {
timing = animate.gen_timing.linear({ duration = 100, unit = "total" }),
},
scroll = {
timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
subscroll = animate.gen_subscroll.equal({
predicate = function(total_scroll)
if mouse_scrolled then
mouse_scrolled = false
return false
end
return total_scroll > 1
end,
}),
},
}
end,
config = function(_, opts)
require("mini.animate").setup(opts)
end,
},
}
For detail information please refer to:
https://github.com/echasnovski/mini.animate
JSON
- Create the file lua/plugin/json.lua
- File the code like this :
return {
-- add json to treesitter
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "json", "json5", "jsonc" })
end
end,
},
-- correctly setup lspconfig
{
"neovim/nvim-lspconfig",
dependencies = {
"b0o/SchemaStore.nvim",
version = false, -- last release is way too old
},
opts = {
-- make sure mason installs the server
servers = {
jsonls = {
-- lazy-load schemastore when needed
on_new_config = function(new_config)
new_config.settings.json.schemas = new_config.settings.json.schemas or {}
vim.list_extend(new_config.settings.json.schemas, require("schemastore").json.schemas())
end,
settings = {
json = {
format = {
enable = true,
},
validate = { enable = true },
},
},
},
},
},
},
}
Markdown Preview
- Create the file lua/plugin/markdown.lua
- Fill the code like this:
return{
"iamcco/markdown-preview.nvim",
event = "BufRead",
build = "cd app && npm install",
config = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
cmd = { "MarkdownPreview", "MarkdownPreviewStop", "MarkdownPreviewToggle" },
}
- For detail information refer to :
https://github.com/iamcco/markdown-preview.nvim
Config Java (JDTLS)
- Intall java and create java home
echo export JAVA_HOME='$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")' | sudo tee /etc/profile.d/jdk_home.sh > /dev/null
echo $JAVA_HOME
- Install Treesitter
:TSInstall java
- Install Mason
:MasonInstall jdtls java-debug-adapter
- Add the plugin in file lua/plugin/init.lua
{ "mfussenegger/nvim-jdtls", event = "BufRead" },
- Buat file ~/.config/nvim/ftplugin/java.lua dan tambahkan code dibawah ini
-- more space in the neovim command line for displaying messages
-- use this function notation to build some variables
vim.opt_local.shiftwidth = 4
vim.opt_local.tabstop = 4
vim.opt_local.softtabstop = 4
vim.opt_local.ts = 4
vim.opt_local.expandtab = true
local status, jdtls = pcall(require, "jdtls")
if not status then
return
end
local function capabilities()
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if status_ok then
return cmp_nvim_lsp.default_capabilities()
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
capabilities.textDocument.completion.completionItem.resolveSupport = {
properties = {
"documentation",
"detail",
"additionalTextEdits",
},
}
return capabilities
end
local function directory_exists(path)
local f = io.popen("cd " .. path)
local ff = f:read("*all")
if ff:find("ItemNotFoundException") then
return false
else
return true
end
end
local root_markers = { ".git", "mvnw", "gradlew", "pom.xml", "build.gradle" }
local root_dir = require("jdtls.setup").find_root(root_markers)
-- calculate workspace dir
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t")
local workspace_dir = vim.fn.stdpath("data") .. "/site/java/workspace-root/" .. project_name
if directory_exists(workspace_dir) then
else
os.execute("mkdir " .. workspace_dir)
end
-- get the mason install path
local install_path = require("mason-registry").get_package("jdtls"):get_install_path()
-- get the current OS
local os
if vim.fn.has("macunix") then
os = "mac"
elseif vim.fn.has("win32") then
os = "win"
else
os = "linux"
end
local bundles = {}
local mason_path = vim.fn.glob(vim.fn.stdpath("data") .. "/mason/")
vim.list_extend(bundles, vim.split(vim.fn.glob(mason_path .. "packages/java-test/extension/server/*.jar"), "\n"))
vim.list_extend(
bundles,
vim.split(
vim.fn.glob(mason_path .. "packages/java-debug-adapter/extension/server/com.microsoft.java.debug.plugin-*.jar"),
"\n"
)
)
local config = {
cmd = {
"java",
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
"-Dosgi.bundles.defaultStartLevel=4",
"-Declipse.product=org.eclipse.jdt.ls.core.product",
"-Dlog.protocol=true",
"-Dlog.level=ALL",
"-javaagent:" .. install_path .. "/lombok.jar",
"-Xms1g",
"--add-modules=ALL-SYSTEM",
"--add-opens",
"java.base/java.util=ALL-UNNAMED",
"--add-opens",
"java.base/java.lang=ALL-UNNAMED",
"-jar",
vim.fn.glob(install_path .. "/plugins/org.eclipse.equinox.launcher_*.jar"),
"-configuration",
install_path .. "/config_" .. os,
"-data",
workspace_dir,
},
capabilities = capabilities(),
root_dir = root_dir,
settings = {
java = {},
},
init_options = {
bundles = {
vim.fn.glob(
mason_path .. "packages/java-debug-adapter/extension/server/com.microsoft.java.debug.plugin-*.jar",
"\n"
),
},
},
}
config["on_attach"] = function(client, bufnr)
local _, _ = pcall(vim.lsp.codelens.refresh)
require("jdtls.dap").setup_dap_main_class_configs()
jdtls.setup_dap({ hotcodereplace = "auto" })
require("user.lsp.handlers").on_attach(client, bufnr)
end
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
pattern = { "*.java" },
callback = function()
local _, _ = pcall(vim.lsp.codelens.refresh)
end,
})
jdtls.start_or_attach(config)
vim.cmd(
[[command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_set_runtime JdtSetRuntime lua require('jdtls').set_runtime(<f-args>)]]
)
Auto Save
{
"Pocco81/auto-save.nvim",
event = "BufRead",
config = function()
require("auto-save").setup({
trigger_events = { "InsertLeave", "BufWinLeave" },
execution_message = {
message = function() -- message to print on save
return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"))
end,
dim = 0.18, -- dim the color of `message`
cleaning_interval = 1250, -- (milliseconds) automatically clean MsgArea after displaying `message`. See :h MsgArea
},
})
end,
},
For Detail Refer to :
https://github.com/Pocco81/auto-save.nvim
Override Lualine
- Create the file lua/plugin/lualine.lua
- Fill the code like this :
return {
"nvim-lualine/lualine.nvim",
event = "BufWinEnter",
config = function()
local status_ok, lualine = pcall(require, "lualine")
if not status_ok then
return
end
local icons = require("user.icons")
local hide_in_width = function()
return vim.fn.winwidth(0) > 80
end
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 80
end,
check_git_workspace = function()
local filepath = vim.fn.expand("%:p:h")
local gitdir = vim.fn.finddir(".git", filepath .. ";")
return gitdir and #gitdir > 0 and #gitdir < #filepath
end,
}
local diagnostics = {
"diagnostics",
sources = { "nvim_diagnostic" },
sections = { "error", "warn" },
-- symbols = { error = " ", warn = " " },
symbols = {
error = icons.diagnostics.BoldError .. " ",
warn = icons.diagnostics.BoldWarning .. " ",
},
colored = true,
update_in_insert = false,
always_visible = false,
}
local diff = {
"diff",
colored = true,
-- symbols = { added = " ", modified = " ", removed = " " }, -- changes diff symbols
symbols = {
added = icons.git.LineAdded .. " ",
modified = icons.git.LineModified .. " ",
removed = icons.git.LineRemoved .. " ",
}, -- changes diff symbols
cond = hide_in_width,
}
local mode = {
"mode",
fmt = function(str)
return " " .. str
-- return " " .. str
end,
}
local filetype = {
"filetype",
icons_enabled = true,
icon = nil,
}
local branch = {
"branch",
icons_enabled = true,
--icon = "",
icon = icons.git.Branch,
}
local location = {
"location",
padding = 0,
}
-- cool function for progress
local progress = function()
local current_line = vim.fn.line(".")
local total_lines = vim.fn.line("$")
local chars = { "__", "▁▁", "▂▂", "▃▃", "▄▄", "▅▅", "▆▆", "▇▇", "██" }
local line_ratio = current_line / total_lines
local index = math.ceil(line_ratio * #chars)
return chars[index]
end
local spaces = function()
-- return "->| " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
return icons.ui.Tab .. " " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
end
local file_name = {
"filename",
cond = conditions.buffer_not_empty,
}
-- start for lsp
local list_registered_providers_names = function(filetype)
local s = require("null-ls.sources")
local available_sources = s.get_available(filetype)
local registered = {}
for _, source in ipairs(available_sources) do
for method in pairs(source.methods) do
registered[method] = registered[method] or {}
table.insert(registered[method], source.name)
end
end
return registered
end
local null_ls = require("null-ls")
-- for formatter
local list_registered = function(filetype)
local method = null_ls.methods.FORMATTING
local registered_providers = list_registered_providers_names(filetype)
return registered_providers[method] or {}
end
--- for linter
local alternative_methods = {
null_ls.methods.DIAGNOSTICS,
null_ls.methods.DIAGNOSTICS_ON_OPEN,
null_ls.methods.DIAGNOSTICS_ON_SAVE,
}
local linter_list_registered = function(filetype)
local registered_providers = list_registered_providers_names(filetype)
local providers_for_methods = vim.tbl_flatten(vim.tbl_map(function(m)
return registered_providers[m] or {}
end, alternative_methods))
return providers_for_methods
end
-- end for lsp
local lsp_info = {
function()
--local msg = "No Active Lsp"
local msg = "LS Inactive"
-- local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
local buf_ft = vim.bo.filetype
local clients = vim.lsp.get_active_clients()
-- start register
local buf_clients = vim.lsp.buf_get_clients()
local buf_client_names = {}
if next(buf_clients) == nil then
-- TODO: clean up this if statement
if type(msg) == "boolean" or #msg == 0 then
return "LS Inactive"
end
return msg
end
-- add client
for _, client in pairs(buf_clients) do
if client.name ~= "null-ls" and client.name ~= "copilot" then
table.insert(buf_client_names, client.name)
end
end
-- add formatter
local supported_formatters = list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_formatters)
-- add linter
local supported_linters = linter_list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_linters)
-- decomple
local unique_client_names = vim.fn.uniq(buf_client_names)
local msg = table.concat(unique_client_names, ", ")
return msg
end,
--icon = " ",
icon = icons.ui.Gear .. "",
}
lualine.setup({
options = {
icons_enabled = true,
theme = "auto",
--component_separators = { left = "", right = "" },
--section_separators = { left = "", right = "" },
-- component_separators = { left = "", right = "" },
-- section_separators = { left = "", right = "" },
component_separators = { left = "", right = "" },
section_separators = { left = "", right = " " },
disabled_filetypes = {
"TelescopePrompt",
"packer",
"alpha",
"dashboard",
"NvimTree",
"Outline",
"DressingInput",
"toggleterm",
"lazy",
"mason",
},
always_divide_middle = true,
},
sections = {
lualine_a = { branch },
lualine_b = { mode },
lualine_c = { diagnostics, lsp_info },
-- lualine_c = { file_name, lsp_info },
-- lualine_x = { "encoding", "fileformat", "filetype" },
lualine_x = { diff, spaces, "encoding", filetype },
lualine_y = { location },
lualine_z = { progress },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = {},
})
end,
}
Config Neotree
- Create the file lua/plugin/neotree.lua
- Fill the code like this :
return {
{ "kyazdani42/nvim-tree.lua", enabled = false },
{
"nvim-neo-tree/neo-tree.nvim",
dependencies={"MunifTanjim/nui.nvim",},
event="BufWinEnter",
cmd = "Neotree",
keys = {
{
"<leader>fE",
function()
require("neo-tree.command").execute({ toggle = true, dir = vim.loop.cwd() })
end,
desc = "Explorer NeoTree (cwd)",
},
{ "<leader>n", "<cmd>Neotree toggle<cr>", desc = "Explorer NeoTree (root dir)", remap = true },
{ "<leader>E", "<leader>fE", desc = "Explorer NeoTree (cwd)", remap = true },
},
deactivate = function()
vim.cmd([[Neotree close]])
end,
init = function()
vim.g.neo_tree_remove_legacy_commands = 1
if vim.fn.argc() == 1 then
local stat = vim.loop.fs_stat(vim.fn.argv(0))
if stat and stat.type == "directory" then
require("neo-tree")
end
end
end,
opts = {
filesystem = {
bind_to_cwd = false,
follow_current_file = true,
},
window = {
position = "left",
width = 30,
mappings = {
["<space>"] = "none",
},
},
default_component_configs = {
icon = {
folder_closed = "",
folder_open = "",
folder_empty = "ﰊ",
-- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
-- then these will never be used.
default = "*",
highlight = "NeoTreeFileIcon"
},
modified = {
symbol = "[+]",
highlight = "NeoTreeModified",
},
git_status = {
symbols = {
-- Change type
added = "✚", -- or "✚", but this is redundant info if you use git_status_colors on the name
modified = "", -- or "", but this is redundant info if you use git_status_colors on the name
deleted = "✖",-- this can only be used in the git_status source
renamed = "",-- this can only be used in the git_status source
-- Status type
untracked = "",
ignored = "",
-- unstaged = "",
unstaged = "",
staged = "",
conflict = "",
}
},
},
},
},
}
- Add key mappings in file lua/custom/whichkey.lua
return {
["e"]={"<cmd>Neotree toggle<cr>","Explorer"},
}
Overide Bufferline
- buat file lua/plugin/bufferline.lua
- Tambahkan code berikut:
return {
"akinsho/bufferline.nvim",
event = "BufWinEnter",
config = function()
local status_ok, bufferline = pcall(require, "bufferline")
if not status_ok then
return
end
local icons = require("user.icons")
local use_icons = true
local function diagnostics_indicator(num, _, diagnostics, _)
local result = {}
local symbols = {
error = icons.diagnostics.Error,
warning = icons.diagnostics.Warning,
info = icons.diagnostics.Information,
}
if not use_icons then
return "(" .. num .. ")"
end
for name, count in pairs(diagnostics) do
if symbols[name] and count > 0 then
table.insert(result, symbols[name] .. " " .. count)
end
end
result = table.concat(result, " ")
return #result > 0 and result or ""
end
bufferline.setup({
options = {
color_icons = true,
numbers = "none", -- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string,
close_command = function(bufnum)
require("bufdelete").bufdelete(bufnum, true)
end,
right_mouse_command = function(bufnum)
require("bufdelete").bufdelete(bufnum, true)
end,
left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions"
middle_mouse_command = nil, -- can be a string | function, see "Mouse actions"
indicator_icon = nil,
indicator = { style = "icon", icon = "▎" },
buffer_close_icon = icons.ui.Close,
modified_icon = icons.ui.Circle,
close_icon = icons.ui.BoldClose,
left_trunc_marker = icons.ui.ArrowCircleLeft,
right_trunc_marker = icons.ui.ArrowCircleRight,
max_name_length = 30,
max_prefix_length = 30, -- prefix used when a buffer is de-duplicated
tab_size = 21,
diagnostics = false, -- | "nvim_lsp" | "coc",
diagnostics_update_in_insert = false,
diagnostics_indicator = diagnostics_indicator,
offsets = {
{
filetype = "NvimTree",
text = "Explorer",
highlight = "Directory",
text_align = "left",
padding = 1,
},
{
filetype = "neo-tree",
text = "Explorer",
highlight = "Directory",
text_align = "left",
padding = 1,
},
},
show_buffer_icons = true,
show_buffer_close_icons = true,
show_close_icon = true,
show_tab_indicators = true,
persist_buffer_sort = true, -- whether or not custom sorted buffers should persist
separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' },
enforce_regular_tabs = true,
always_show_bufferline = true,
},
highlights = {
fill = {
fg = { attribute = "fg", highlight = "#ff0000" },
bg = { attribute = "bg", highlight = "TabLine" },
},
background = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
buffer_visible = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
close_button = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
close_button_visible = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
tab_selected = {
fg = { attribute = "fg", highlight = "Normal" },
bg = { attribute = "bg", highlight = "Normal" },
},
tab = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
tab_close = {
fg = { attribute = "fg", highlight = "TabLineSel" },
bg = { attribute = "bg", highlight = "Normal" },
},
duplicate_selected = {
fg = { attribute = "fg", highlight = "TabLineSel" },
bg = { attribute = "bg", highlight = "TabLineSel" },
underline = true,
},
duplicate_visible = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
underline = true,
},
duplicate = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
underline = true,
},
modified = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
modified_selected = {
fg = { attribute = "fg", highlight = "Normal" },
bg = { attribute = "bg", highlight = "Normal" },
},
modified_visible = {
fg = { attribute = "fg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
separator = {
fg = { attribute = "bg", highlight = "TabLine" },
bg = { attribute = "bg", highlight = "TabLine" },
},
separator_selected = {
fg = { attribute = "bg", highlight = "Normal" },
bg = { attribute = "bg", highlight = "Normal" },
},
indicator_selected = {
fg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" },
bg = { attribute = "bg", highlight = "Normal" },
},
},
})
end,
}
Typescript (jose-elias-alvarez)
- Unregister LSP (buka file lua/custom/register_lsp.lua) tambahkan code berikut :
skipreg = {
"tsserver",
},
- Lakukan install mason
:MasonInstall typescript-language-server prettier
- Lakukan Install Treesitter
:TSInstall javascript typescript tsx
- Buat file lua/plugin/typecript.lua
return {
"jose-elias-alvarez/typescript.nvim",
event = "BufRead",
dependencies = { "williamboman/mason-lspconfig.nvim" },
config = function()
require("typescript").setup({
disable_commands = false, -- prevent the plugin from creating Vim commands
debug = false, -- enable debug logging for commands
go_to_source_definition = {
fallback = true, -- fall back to standard LSP definition on failure
},
server = { -- pass options to lspconfig's setup method
on_attach = require("user.lsp.handlers").on_attach,
capabilities = require("user.lsp.handlers").capabilities,
},
})
end,
}
sumber :
https://github.com/jose-elias-alvarez/typescript.nvim
Denols (deno-nvim)
- Unregister LSP (buka file lua/custom/register_lsp.lua) tambahkan code berikut :
skipreg = {
"denols",
},
- Lakukan install mason
:MasonInstall deno prettier
- Lakukan Install Treesitter
:TSInstall javascript typescript tsx
- Buat file lua/plugin/denols.lua
return {
"sigmasd/deno-nvim",
event = "BufRead",
dependencies = { "williamboman/mason-lspconfig.nvim" },
config = function()
require("deno-nvim").setup({
server = {
on_attach = require("user.lsp.handlers").on_attach,
capabilities = require("user.lsp.handlers").capabilities,
},
})
end,
}
sumber: https://github.com/sigmaSd/deno-nvim
clangd (clangd_extensions.nvim)
- Unregister LSP (buka file lua/custom/register_lsp.lua) tambahkan code berikut :
skipreg = {
"clangd",
},
- Lakukan install mason
:MasonInstall clangd clang-format
- Lakukan Install Treesitter
:TSInstall cpp c
- Buat file lua/plugin/clangd.lua
return {
"p00f/clangd_extensions.nvim",
dependencies = { "williamboman/mason-lspconfig.nvim" },
event = "BufRead",
config = function()
require("clangd_extensions").setup({
server = {
on_attach = require("user.lsp.handlers").on_attach,
capabilities = {
offsetEncoding = "utf-8",
require("user.lsp.handlers").capabilities,
},
},
})
end,
}
- add null-ls config lua/custom/null-ls.lua
local null_ls = require("null-ls")
local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics
local m = {
sources = {
formatting.clang_format.with({
filetypes = {
"cpp",
"c",
},
}),
},
}
return m
sumber :
https://github.com/p00f/clangd_extensions.nvim
Config Flutter Tool
- Pastikan sudah install dart dan flutter sdk
https://dart.dev/get-dart
https://docs.flutter.dev/get-started/install - cek pastikan path terregistrasi
which flutter dart
- install treesitter
:TSInstall dart
- install dap
:MasonInstall dart-debug-adapter
- Buat file lua/plugin/flutter-tool.lua
return {
"akinsho/flutter-tools.nvim",
dependencies = { "williamboman/mason-lspconfig.nvim", "nvim-lua/plenary.nvim" },
event = "BufRead",
config = function()
require("flutter-tools").setup({
server = {
color = {
enabled = true,
},
settings = {
showTodos = true,
completeFunctionCalls = true,
},
on_attach = require("user.lsp.handlers").on_attach,
capabilities = {
require("user.lsp.handlers").capabilities,
},
},
})
end,
}
- but file nvim/ftplugin/dart.lua
local dap = require("dap")
dap.adapters.dart = {
type = "executable",
command = "dart",
-- This command was introduced upstream in https://github.com/dart-lang/sdk/commit/b68ccc9a
args = { "debug_adapter" },
}
dap.configurations.dart = {
{
type = "dart",
request = "launch",
name = "Launch Dart Program",
-- The nvim-dap plugin populates this variable with the filename of the current buffer
program = "${file}",
-- The nvim-dap plugin populates this variable with the editor's current working directory
cwd = "${workspaceFolder}",
args = { "--help" }, -- Note for Dart apps this is args, for Flutter apps toolArgs
},
}
- config formatter cari file lua/custom/null-ls.lua
local null_ls = require("null-ls")
local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics
local m = {
sources = {
formatting.dart_format,
},
}
return m
sumber :
https://github.com/akinsho/flutter-tools.nvim
https://gist.github.com/christopherfujino/80be0f4cd88f75c4991b478e6b071153
Config rust-tools
-
Pastikan sudah install Rust
https://www.rust-lang.org/tools/install -
Install Treesitter
:TSInstall rust toml
- Mason Install
:MasonInstall rust-analizer codelldb rustfmt
- Buat file lua/plugin/rust-analizer.lua
return {
"simrat39/rust-tools.nvim",
event = "BufRead",
dependencies = {
"mason-lspconfig.nvim",
{
"saecki/crates.nvim",
tag = "v0.3.0",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
require("crates").setup({
null_ls = {
enabled = true,
name = "crates.nvim",
},
popup = {
border = "rounded",
},
})
end,
},
},
config = function()
local mason_path = vim.fn.glob(vim.fn.stdpath("data") .. "/mason/")
local codelldb_adapter = {
type = "server",
port = "${port}",
executable = {
command = mason_path .. "bin/codelldb",
args = { "--port", "${port}" },
-- On windows you may have to uncomment this:
-- detached = false,
},
}
local rt = require("rust-tools")
rt.setup({
tools = {
executor = require("rust-tools/executors").termopen, -- can be quickfix or termopen
reload_workspace_from_cargo_toml = true,
runnables = {
use_telescope = true,
},
inlay_hints = {
auto = true,
only_current_line = false,
show_parameter_hints = false,
parameter_hints_prefix = "<-",
other_hints_prefix = "=>",
max_len_align = false,
max_len_align_padding = 1,
right_align = false,
right_align_padding = 7,
highlight = "Comment",
},
hover_actions = {
border = "rounded",
},
on_initialized = function()
vim.api.nvim_create_autocmd({ "BufWritePost", "BufEnter", "CursorHold", "InsertLeave" }, {
pattern = { "*.rs" },
callback = function()
local _, _ = pcall(vim.lsp.codelens.refresh)
end,
})
end,
},
dap = {
adapter = codelldb_adapter,
},
server = {
on_attach = function(client, bufnr)
require("user.lsp.handlers").on_attach(client, bufnr)
local rt = require("rust-tools")
vim.keymap.set("n", "K", rt.hover_actions.hover_actions, { buffer = bufnr })
end,
capabilities = require("user.lsp.handlers").capabilities,
settings = {
["rust-analyzer"] = {
lens = {
enable = true,
},
checkOnSave = {
enable = true,
command = "clippy",
},
},
},
},
})
local dap = require("dap")
dap.adapters.codelldb = codelldb_adapter
dap.configurations.rust = {
{
name = "Launch file",
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
},
}
vim.api.nvim_set_keymap("n", "<m-d>", "<cmd>RustOpenExternalDocs<Cr>", { noremap = true, silent = true })
end,
}
- Tambahkan whichkey lua/custom/whichkey.lua
return{
["C"] = {
name = "Rust",
r = { "<cmd>RustRunnables<Cr>", "Runnables" },
t = { "<cmd>lua _CARGO_TEST()<cr>", "Cargo Test" },
m = { "<cmd>RustExpandMacro<Cr>", "Expand Macro" },
c = { "<cmd>RustOpenCargo<Cr>", "Open Cargo" },
p = { "<cmd>RustParentModule<Cr>", "Parent Module" },
d = { "<cmd>RustDebuggables<Cr>", "Debuggables" },
v = { "<cmd>RustViewCrateGraph<Cr>", "View Crate Graph" },
R = {
"<cmd>lua require('rust-tools/workspace_refresh')._reload_workspace_from_cargo_toml()<Cr>",
"Reload Workspace",
},
o = { "<cmd>RustOpenExternalDocs<Cr>", "Open External Docs" },
y = { "<cmd>lua require'crates'.open_repository()<cr>", "[crates] open repository" },
P = { "<cmd>lua require'crates'.show_popup()<cr>", "[crates] show popup" },
i = { "<cmd>lua require'crates'.show_crate_popup()<cr>", "[crates] show info" },
f = { "<cmd>lua require'crates'.show_features_popup()<cr>", "[crates] show features" },
D = { "<cmd>lua require'crates'.show_dependencies_popup()<cr>", "[crates] show dependencies" },
},
}
Sumber :
https://github.com/simrat39/rust-tools.nvim
Rekomendasi Colorscheme
{ "dracula/vim" },
vim.cmd("colorscheme dracula")
{"lunarvim/darkplus.nvim"}
vim.cmd("colorscheme darkplus")
- https://github.com/folke/tokyonight.nvim
- https://github.com/arcticicestudio/nord-vim
- https://github.com/sainnhe/sonokai
- https://github.com/RRethy/nvim-base16
- https://github.com/navarasu/onedark.nvim
- https://github.com/marko-cerovac/material.nvim
- https://github.com/LunarVim/lunar.nvim
symbols-outline.nvim
- tambahkan file lua/plugin/symbol-outline.lua
return{
"simrat39/symbols-outline.nvim",
event = "BufRead",
config = function()
require("symbols-outline").setup()
end,
}
- Tambahkan pada lua/custom/whichkey.lua
return{
["o"] = { "<cmd>SymbolsOutline<cr>", "Symbol Outline" },
}
Sumber : https://github.com/simrat39/symbols-outline.nvim
trouble.nvim
- but file lua/plugin/trouble.lua
return{
"folke/trouble.nvim",
event = "BufRead",
cmd = { "TroubleToggle", "Trouble" },
opts = { use_diagnostic_signs = true },
keys = {
{ "<leader>xx", "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" },
{ "<leader>xX", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" },
},
}
summer : https://github.com/folke/trouble.nvim
Mini Indentscope
- but file lua/plugin/minianimate.lua
return{
"echasnovski/mini.indentscope",
version = false, -- wait till new 0.7.0 release to put it back on semver
event = "BufReadPre",
opts = {
-- symbol = "▏",
symbol = "│",
options = { try_as_border = true },
},
config = function(_, opts)
vim.api.nvim_create_autocmd("FileType", {
pattern = { "help", "alpha", "dashboard", "NvimTree", "Trouble", "lazy", "mason" },
callback = function()
vim.b.miniindentscope_disable = true
end,
})
require("mini.indentscope").setup(opts)
end,
}
summer : https://github.com/echasnovski/mini.indentscope
yanky.nvim
- but file lua/plugin/yanky.lua
return{
"gbprod/yanky.nvim",
event = "BufRead",
config = function()
local status_ok, yanky = pcall(require, "yanky")
if not status_ok then
return
end
yanky.setup({
ring = {
history_length = 50,
storage = "memory",
},
preserve_cursor_position = {
enabled = false,
},
})
-- cycle through the yank history, only work after paste
vim.keymap.set("n", "[y", "<plug>(yankycycleforward)")
vim.keymap.set("n", "]y", "<plug>(yankycyclebackward)")
end,
}
summer :
https://github.com/gbprod/yanky.nvim
Code Runner
- but file lua/plugin/nvimjaq.lua
return{
"is0n/jaq-nvim",
event = "BufRead",
config = function()
M = {}
local status_ok, jaq_nvim = pcall(require, "jaq-nvim")
if not status_ok then
return
end
jaq_nvim.setup({
-- Commands used with 'Jaq'
cmds = {
-- Default UI used (see `Usage` for options)
default = "term",
-- Uses external commands such as 'g++' and 'cargo'
external = {
typescript = "deno run %",
javascript = "node %",
-- markdown = "glow %",
python = "python %",
-- rust = "rustc % && ./$fileBase && rm $fileBase",
rust = "cargo run",
cpp = "g++ % -o $fileBase && ./$fileBase",
go = "go run %",
sh = "sh %",
java = "java %",
},
-- Uses internal commands such as 'source' and 'luafile'
internal = {
-- lua = "luafile %",
-- vim = "source %",
},
},
behavior = {
-- Default type
default = "terminal",
-- Start in insert mode
startinsert = false,
-- Use `wincmd p` on startup
wincmd = false,
-- Auto-save files
autosave = false,
},
-- UI settings
ui = {
-- Floating Window / FTerm settings
float = {
-- Floating window border (see ':h nvim_open_win')
border = "rounded", -- none, single, double, rounded
-- Num from `0 - 1` for measurements
height = 0.8,
width = 0.8,
x = 0.5,
y = 0.5,
-- Highlight group for floating window/border (see ':h winhl')
border_hl = "FloatBorder",
float_hl = "Normal",
-- Floating Window Transparency (see ':h winblend')
blend = 0,
},
terminal = {
-- Position of terminal
position = "bot",
-- Open the terminal without line numbers
line_no = false,
-- Size of terminal
size = 20,
},
},
})
local opts = { noremap = true, silent = true }
local keymap = vim.api.nvim_set_keymap
keymap("n", "<m-r>", ":silent only | Jaq<cr>", opts)
return M
end,
}
- tambahkan lua/custom whichkey.lua
return{
["r"] = {
name = "Run",
j = { "<cmd>Jaq float<CR>", "Run With Jaq" },
},
}
summer: https://github.com/is0n/jaq-nvim
todo-comments.nvim
- but file lua/plugin/todocomment.lua
return{
"folke/todo-comments.nvim",
event = "BufRead",
config = function()
require("todo-comments").setup()
end,
}
- tambahkan key map lua/default/keymaps.lua
map("n", "]t", function()
require("todo-comments").jump_next()
end, { desc = "Next todo comment" })
map("n", "[t", function()
require("todo-comments").jump_prev()
end, { desc = "Previous todo comment" })
summer : https://github.com/folke/todo-comments.nvim
- alternative lainnya
-- TODO: example
-- FIX: contoh fix
-- WARNING
-- ! custom option
return {
"Djancyp/better-comments.nvim",
event = "BufRead",
config = function()
require("better-comment").Setup()
end,
}
summer :
https://github.com/Djancyp/better-comments.nvim
Neoscroll
- but file lua/plugin/neoscroll.lua
return{
"karb94/neoscroll.nvim",
event = "BufRead",
config = function()
require("neoscroll").setup()
end,
}
summer : https://github.com/karb94/neoscroll.nvim
Laravel Nvim
- nuat file lua/plugin/laravel.lua
return {
"adalessa/laravel.nvim",
dependencies = {
"nvim-telescope/telescope.nvim",
},
cmd = { "Sail", "Artisan", "Composer" },
keys = {
{ "<leader>pa", ":Artisan<cr>" },
},
config = function()
require("laravel").setup()
require("telescope").load_extension("laravel")
end,
}
summer : https://github.com/adalessa/laravel.nvim
CMP Cmdline
- but file lua/plugin/cmdline.lua
-- initial gui app
local is_neovide = false
local use_noice = true
if vim.g.neovide then
is_neovide = true
use_noice = false
end
vim.opt.lazyredraw = is_neovide
return {
{ "gelguy/wilder.nvim", enabled = not use_noice },
{
"folke/noice.nvim",
lazy = true,
enabled = use_noice,
dependencies = {
{ "MunifTanjim/nui.nvim", enabled = use_noice },
},
event = "BufWinEnter",
opts = {
messages = {
enabled = false,
},
notify = {
enabled = false,
},
lsp = {
progress = {
enabled = false,
},
hover = {
enabled = false,
},
signature = {
enabled = false,
},
},
},
keys = {
{
"<S-Enter>",
function()
require("noice").redirect(vim.fn.getcmdline())
end,
mode = "c",
desc = "Redirect Cmdline",
},
{
"<leader>snl",
function()
require("noice").cmd("last")
end,
desc = "Noice Last Message",
},
{
"<leader>snh",
function()
require("noice").cmd("history")
end,
desc = "Noice History",
},
{
"<leader>sna",
function()
require("noice").cmd("all")
end,
desc = "Noice All",
},
{
"<c-f>",
function()
if not require("noice.lsp").scroll(4) then
return "<c-f>"
end
end,
silent = true,
expr = true,
desc = "Scroll forward",
mode = { "i", "n", "s" },
},
{
"<c-b>",
function()
if not require("noice.lsp").scroll(-4) then
return "<c-b>"
end
end,
silent = true,
expr = true,
desc = "Scroll backward",
mode = { "i", "n", "s" },
},
},
},
{
"hrsh7th/cmp-cmdline",
event = "VeryLazy",
config = function()
local cmp = require("cmp")
local mapping = {
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
["<S-Tab>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
["<Down>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
["<Tab>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
}
-- Use buffer source for `/`.
cmp.setup.cmdline("/", {
preselect = "none",
completion = {
completeopt = "menu,preview,menuone,noselect",
},
mapping = mapping,
sources = {
{ name = "buffer" },
},
experimental = {
ghost_text = true,
native_menu = false,
},
})
-- Use cmdline & path source for ':'.
cmp.setup.cmdline(":", {
preselect = "none",
completion = {
completeopt = "menu,preview,menuone,noselect",
},
mapping = mapping,
sources = cmp.config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
experimental = {
ghost_text = true,
native_menu = false,
},
})
end,
},
}
Sumber :
https://github.com/folke/noice.nvim
https://github.com/hrsh7th/cmp-cmdline
nvim-treesitter-context
- but file lua/plugin/context.lua
return {
{
"romgrk/nvim-treesitter-context",
event = "BufRead",
config = function()
require("treesitter-context").setup({
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)
throttle = true, -- Throttles plugin updates (may improve performance)
max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit.
patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries.
-- For all filetypes
-- Note that setting an entry here replaces all other patterns for this entry.
-- By setting the 'default' entry below, you can control which nodes you want to
-- appear in the context window.
default = {
"class",
"function",
"method",
},
},
})
end,
},
}
Sumber :
https://github.com/nvim-treesitter/nvim-treesitter-context
Golang Setup
- install treesitter
:TSInstall go gomod
- Mason Install
:MasonInstall gopls golangci-lint-langserver delve goimports gofumpt gomodifytags gotests impl go-debug-adapter
- but file lua/plugin/golang.lua
return {
{
"olexsmir/gopher.nvim",
config = function()
require("gopher").setup({
commands = {
go = "go",
gomodifytags = "gomodifytags",
gotests = "gotests",
impl = "impl",
iferr = "iferr",
},
})
end,
},
{
"leoluz/nvim-dap-go",
config = function()
require("dap-go").setup()
end,
},
}
- Register LSP pada file lua/custom/default.lua
vim.g.pcode_register_lsp = {
"gopls",
}
- Config code runner lua/custom/default.lua
vim.g.pcode_coderunner = {
go = "go run $fileName",
}
summer :
https://github.com/olexsmir/gopher.nvim
https://github.com/leoluz/nvim-dap-go
Color Scheme Github Dark Nvim
- Tambahkan config pada plugin
return {
{
"navarasu/onedark.nvim",
enabled = false,
},
{
"projekt0n/github-nvim-theme",
lazy = false, -- make sure we load this during startup if it is your main colorscheme
priority = 1000, -- make sure to load this before all the other start plugins
config = function()
local is_transparent = false
local palette = require("github-theme.palette").load("github_dark_dimmed")
require("github-theme").setup({
options = {
-- Compiled file's destination location
compile_path = vim.fn.stdpath("cache") .. "/github-theme",
compile_file_suffix = "_compiled", -- Compiled file suffix
hide_end_of_buffer = true, -- Hide the '~' character at the end of the buffer for a cleaner look
hide_nc_statusline = true, -- Override the underline style for non-active statuslines
transparent = is_transparent, -- Disable setting background
terminal_colors = true, -- Set terminal colors (vim.g.terminal_color_*) used in `:terminal`
dim_inactive = false, -- Non focused panes set to alternative background
module_default = true, -- Default enable value for modules
styles = { -- Style to be applied to different syntax groups
comments = "italic", -- Value is any valid attr-list value `:help attr-list`
functions = "italic",
keywords = "NONE",
variables = "NONE",
conditionals = "NONE",
constants = "NONE",
numbers = "NONE",
operators = "NONE",
strings = "NONE",
types = "NONE",
},
inverse = { -- Inverse highlight for different types
match_paren = false,
visual = false,
search = false,
},
darken = { -- Darken floating windows and sidebar-like windows
floats = false,
sidebars = {
enabled = true,
list = {}, -- Apply dark background to specific windows
},
},
modules = { -- List of various plugins and additional options
-- ...
},
},
palettes = {
github_dark_dimmed = {
bg0 = is_transparent and "NONE" or "bg1",
bg1 = is_transparent and "NONE" or "bg",
},
},
specs = {},
groups = {
all = {
illuminatedWord = { bg = "#3b4261" },
illuminatedCurWord = { bg = "#3b4261" },
IlluminatedWordText = { bg = "#3b4261" },
IlluminatedWordRead = { bg = "#3b4261" },
IlluminatedWordWrite = { bg = "#3b4261" },
["@tag.attribute"] = { fg = "#77bdfb", style = "italic" },
["@text.uri"] = { fg = palette.const, style = "italic" },
-- ["@tag.attribute.html"] = { fg = "#faa356", style = "italic" },
-- ["@operator.html"] = { fg = "#faa356" },
-- ["@tag.html"] = { fg = "#fa7970" },
-- ["@tag.delimiter.html"] = { fg = "#faa356" },
},
github_dark_high_contrast = {
NvimTreeSpecialFile = { fg = "#faa356", style = "italic" },
},
github_dark_dimmed = {
-- As with specs and palettes, a specific style's value will be used over the `all`'s value.
NvimTreeNormal = { fg = "fg1", bg = is_transparent and "NONE" or "bg1" },
NvimTreeSpecialFile = { fg = "#faa356", style = "italic" },
BufferLineFill = { bg = is_transparent and "NONE" or "bg1" },
BufferLineUnfocusedFill = { bg = is_transparent and "NONE" or "bg1" },
LualineNormal = { bg = is_transparent and "NONE" or "bg1" },
StatusLine = { bg = is_transparent and "NONE" or "bg1" },
StatusLineTerm = { bg = is_transparent and "NONE" or "bg1" },
Pmenu = { bg = is_transparent and "NONE" or "bg1" },
PmenuSel = { link = "CursorLine" },
WhichKeyFloat = { bg = is_transparent and "NONE" or "bg1" },
LazyNormal = { bg = is_transparent and "NONE" or "bg1" },
LazyBackground = { bg = is_transparent and "NONE" or "bg1" },
},
},
})
end,
},
}
- load Colorscheme
vim.cmd("colorscheme github_dark_dimmed")
Color Scheme OnedarkPro
- tambahkan config plugin
return {
{ "navarasu/onedark.nvim", enabled = false },
{
"olimorris/onedarkpro.nvim",
priority = 1000, -- Ensure it loads first
config = function()
local is_transparent = false
require("onedarkpro").setup({
styles = {
types = "NONE",
methods = "NONE",
numbers = "NONE",
strings = "NONE",
comments = "italic",
-- keywords = "bold,italic",
keywords = "italic",
constants = "NONE",
functions = "NONE",
operators = "NONE",
variables = "NONE",
parameters = "NONE",
conditionals = "italic",
virtual_text = "NONE",
tags = "italic",
},
colors = {
onedark = {
green = "#99c379",
gray = "#8094b4",
red = "#e06c75",
purple = "#c678dd",
yellow = "#e5c07a",
blue = "#61afef",
cyan = "#56b6c2",
bg_statusline = "#282c34",
indentline = "#3b4261",
float_bg = "#282c34",
},
},
filetypes = {
-- javascript = false,
},
options = {
cursorline = true, -- Use cursorline highlighting?
transparency = is_transparent, -- Use a transparent background?
terminal_colors = true, -- Use the theme's colors for Neovim's :terminal?
lualine_transparency = is_transparent, -- Center bar transparency?
highlight_inactive_windows = false, -- When the window is out of focus, change the normal background?
},
highlights = {
-- overide cursor line fill colors
LineNr = { fg = "#49505E" }, -- Line number for ":number" and ":#" commands, and when 'number' or 'relativenumber' option is set.
CursorLineNr = { fg = "${blue}" }, -- Like LineNr when 'cursorline' or 'relativenumber' is set for the cursor line.
CursorLine = { bg = "#333842" },
Cursor = { fg = "${bg}", bg = "${fg}" }, -- character under the cursor
lCursor = { fg = "${bg}", bg = "${fg}" }, -- the character under the cursor when |language-mapping| is used (see 'guicursor')
CursorIM = { fg = "${bg}", bg = "${fg}" }, -- like Cursor, but used when in IME mode |CursorIM|
CursorColumn = { bg = "#333842" }, -- Screen-column at the cursor, when 'cursorcolumn' is set.
-- overide nvimtree folder icon fill color
NvimTreeFolderIcon = { fg = "${gray}" },
-- overide nvimtree text fill color folder opened
NvimTreeOpenedFolderName = { fg = "${blue}" },
-- overide nvimtree text fill color root folder
NvimTreeRootFolder = { fg = "${blue}" },
NvimTreeSpecialFile = { fg = "${orange}" },
NvimTreeWinSeparator = { fg = "#202329" },
NvimTreeIndentMarker = { fg = "#3E4450" },
-- overide indenline fill color
IblIndent = { fg = "#3E4450" },
-- overide cmp cursorline fill color with #333842
PmenuSel = { bg = "#333842" },
illuminatedWord = { bg = "#3b4261" },
illuminatedCurWord = { bg = "#3b4261" },
IlluminatedWordText = { bg = "#3b4261" },
IlluminatedWordRead = { bg = "#3b4261" },
IlluminatedWordWrite = { bg = "#3b4261" },
StatusLine = { fg = "#f8f8f2", bg = is_transparent and "NONE" or "${bg}" },
StatusLineTerm = { fg = "#f8f8f2", bg = "${bg}" },
BufferLineFill = { bg = is_transparent and "NONE" or "${bg}" },
["@string.special.url.html"] = { fg = "${green}" },
["@text.uri.html"] = { fg = "${green}" },
["@tag.javascript"] = { fg = "${red}" },
["@tag.attribute"] = { fg = "${orange}", style = "italic" },
["@constructor.javascript"] = { fg = "${red}" },
-- ["@variable"] = { fg = "${fg}", style = "NONE" }, -- various variable names
["@variable.builtin"] = { fg = "${red}", style = "NONE" },
["@variable.member"] = "${cyan}",
["@variable.parameter"] = "${red}",
-- ["@property.javascript"] = { fg = "${cyan}" }, -- similar to `@field`
["@lsp.type.parameter"] = { fg = "${fg}" },
["@lsp.type.property.lua"] = { fg = "${red}" },
["@lsp.type.variable"] = { fg = "${fg}" },
NvimTreeGitDirty = { fg = "${yellow}" },
Pmenu = { fg = "${fg}", bg = "${bg}" },
PmenuThumb = { bg = "${gray}" }, -- Popup menu: Thumb of the scrollbar.
-- overide lualine fill color with bg color
LualineNormal = { bg = "${bg}" },
-- overide lualine_c fill color with bg color
LualineC = { bg = "${bg}" },
-- overide lualine_x fill color with bg color
LualineX = { bg = "${bg}" },
-- overide which-key fill color with bg color
-- WhichKey = { bg = "${bg}" },
-- -- overide which-key fill color with bg color
-- WhichKeySeperator = { bg = "${bg}" },
-- -- overide which-key fill color with bg color
-- WhichKeyDesc = { fg = "${red}" },
-- -- overide which-key fill color with bg color
-- WhichKeyFloat = { bg = "${bg}" },
WhichKeyFloat = { bg = is_transparent and "NONE" or "${bg}" },
-- -- overide which-key fill color with bg color
-- WhichKeyValue = { bg = "${bg}" },
-- -- overide which-key fill color with bg color
-- WhichKeyBorder = { bg = "${bg}" },
-- Folded = { bg = "NONE", fg = "${fg}" }, -- line used for closed folds
TermCursor = { bg = "${fg}" },
TSRainbowRed = { fg = "${cyan}" },
TSRainbowCyan = { fg = "${red}" },
},
})
end,
},
}
- load Colorscheme
vim.cmd("colorscheme onedark")
sumber :
https://github.com/olimorris/onedarkpro.nvim
Codeium
- install Kebutuhan untuk WSL2
sudo apt-get install uuid-runtime
- but file lua/plugin/codeium.lua
vim.g.codeium_disable_bindings = 1
return {
"Exafunction/codeium.vim",
event = "VeryLazy",
config = function()
-- Change '<C-g>' here to any keycode you like.
vim.keymap.set("i", "<C-g>", function()
return vim.fn["codeium#Accept"]()
end, { expr = true })
vim.keymap.set("i", "<c-;>", function()
return vim.fn["codeium#CycleCompletions"](1)
end, { expr = true })
vim.keymap.set("i", "<c-,>", function()
return vim.fn["codeium#CycleCompletions"](-1)
end, { expr = true })
vim.keymap.set("i", "<c-x>", function()
return vim.fn["codeium#Clear"]()
end, { expr = true })
end,
}
summer :
https://www.codeium.com/
https://github.com/Exafunction/codeium.vim
Code Window
- but file lua/plugin/codewindow.lua
return {
{ "dstein64/nvim-scrollview", enabled = false },
{
"gorbit99/codewindow.nvim",
event = "VimEnter",
config = function()
local codewindow = require("codewindow")
codewindow.setup({
auto_enable = true,
minimap_width = 10,
window_border = nil,
exclude_filetypes = {
"TelescopePrompt",
"packer",
"alpha",
"dashboard",
"NvimTree",
"Outline",
"DressingInput",
"toggleterm",
"lazy",
"mason",
"neo-tree",
},
})
codewindow.apply_default_keybinds()
end,
},
}
- mapping
["w"] = {
name = "MiniMap",
o = { "<cmd>lua require('codewindow').open_minimap()<cr>", "Open Maps" },
c = { "<cmd>lua require('codewindow').close_minimap()<cr>", "Close Maps" },
f = { "<cmd>lua require('codewindow').toggle_focus()<cr>", "Focus Maps" },
},
Sumber :
https://github.com/gorbit99/codewindow.nvim
LSP Line
- but file lua/plugin/lsp-line.lua
return {
"ErichDonGubler/lsp_lines.nvim",
event = "VimEnter",
config = function()
require("lsp_lines").setup()
vim.api.nvim_create_autocmd("FileType", {
pattern = { "*" }, --ini untuk file yang tidak ingin dibaca
callback = function()
local exclude_ft = {
"lazy",
}
if vim.tbl_contains(exclude_ft, vim.o.filetype) then
vim.diagnostic.config({ virtual_lines = false })
else
vim.diagnostic.config({ virtual_lines = true })
end
end,
})
end,
}
- disable virtual text
- cari file lua/custom/default.lua ubah jadi false
vim.g.pcode_lsp_virtualtext = false
summer :
https://github.com/ErichDonGubler/lsp_lines.nvim
MiniMap 2
- but file lua/plugin/minimap.lua
return {
{ "dstein64/nvim-scrollview", enabled = false },
{
"echasnovski/mini.map",
branch = "stable",
event = "BufWinEnter",
config = function()
require("mini.map").setup()
local map = require("mini.map")
map.setup({
integrations = {
map.gen_integration.builtin_search(),
map.gen_integration.diagnostic({
error = "DiagnosticFloatingError",
warn = "DiagnosticFloatingWarn",
info = "DiagnosticFloatingInfo",
hint = "DiagnosticFloatingHint",
}),
},
symbols = {
encode = map.gen_encode_symbols.dot("4x2"),
},
window = {
side = "right",
width = 10, -- set to 1 for a pure scrollbar :)
winblend = 15,
show_integration_count = false,
},
})
end,
},
}
- create auto command lua/default/autocommands.lua
-- custom auto comman disini
vim.api.nvim_create_autocmd("FileType", {
pattern = "*",
callback = function()
local exclude_ft = {
"qf",
"NvimTree",
"toggleterm",
"TelescopePrompt",
"alpha",
"netrw",
}
local map = require("mini.map")
if vim.tbl_contains(exclude_ft, vim.o.filetype) then
vim.b.minimap_disable = true
map.close()
elseif vim.o.buftype == "" then
map.open()
end
end,
})
- but mapping pada file lua/custom/default.lua
vim.g.pcode_whichkey = {
["m"] = {
name = "Minimap",
c = { "<cmd>lua require('mini.map').close()<cr>", "Minimap Close" },
o = { "<cmd>lua require('mini.map').open()<cr>", "Minimap Open" },
},
}
summer :
https://github.com/echasnovski/mini.map
Overide Lualine
- buat file lua/plugin/lualine.lua
- Tambahkan code berikut
return {
{
"nvim-lualine/lualine.nvim",
event = "BufWinEnter",
config = function()
local hide_in_width = function()
return vim.fn.winwidth(0) > 80
end
local icons = require("user.icons")
-- start for lsp
local list_registered_providers_names = function(filetype)
local s = require("null-ls.sources")
local available_sources = s.get_available(filetype)
local registered = {}
for _, source in ipairs(available_sources) do
for method in pairs(source.methods) do
registered[method] = registered[method] or {}
table.insert(registered[method], source.name)
end
end
return registered
end
local null_ls = require("null-ls")
-- for formatter
local list_registered = function(filetype)
local method = null_ls.methods.FORMATTING
local registered_providers = list_registered_providers_names(filetype)
return registered_providers[method] or {}
end
--- for linter
local alternative_methods = {
null_ls.methods.DIAGNOSTICS,
null_ls.methods.DIAGNOSTICS_ON_OPEN,
null_ls.methods.DIAGNOSTICS_ON_SAVE,
}
local linter_list_registered = function(filetype)
local registered_providers = list_registered_providers_names(filetype)
local providers_for_methods = vim.tbl_flatten(vim.tbl_map(function(m)
return registered_providers[m] or {}
end, alternative_methods))
return providers_for_methods
end
-- end for lsp
local lsp_info = {
function()
local msg = "LS Inactive"
local buf_ft = vim.bo.filetype
local clients = vim.lsp.get_active_clients()
-- start register
local buf_clients = vim.lsp.buf_get_clients()
local buf_client_names = {}
if next(buf_clients) == nil then
-- TODO: clean up this if statement
if type(msg) == "boolean" or #msg == 0 then
return "LS Inactive"
end
return msg
end
-- add client
for _, client in pairs(buf_clients) do
if client.name ~= "null-ls" and client.name ~= "copilot" then
table.insert(buf_client_names, client.name)
end
end
-- add formatter
local supported_formatters = list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_formatters)
-- add linter
local supported_linters = linter_list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_linters)
-- decomple
local unique_client_names = vim.fn.uniq(buf_client_names)
local msg = table.concat(unique_client_names, ", ")
return msg
end,
--icon = " ",
icon = icons.ui.Gear .. "",
padding = 1,
}
local diagnostics = {
"diagnostics",
sources = { "nvim_diagnostic" },
sections = { "error", "warn" },
-- symbols = { error = " ", warn = " " },
symbols = {
error = icons.diagnostics.BoldError .. " ",
warn = icons.diagnostics.BoldWarning .. " ",
},
colored = true,
update_in_insert = false,
always_visible = false,
}
local diff = {
"diff",
colored = true,
-- symbols = { added = " ", modified = " ", removed = " " }, -- changes diff symbols
symbols = {
added = icons.git.LineAdded .. " ",
modified = icons.git.LineModified .. " ",
removed = icons.git.LineRemoved .. " ",
}, -- changes diff symbols
cond = hide_in_width,
}
local spaces = function()
-- return " " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
return icons.ui.Tab .. " " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
end
local mode = {
"mode",
padding = 1,
separator = { left = "", right = "" },
right_padding = 3,
fmt = function(str)
return " " .. str
end,
}
-- stylua: ignore
local colors = {
blue = '#9ece6a',
cyan = '#bb9af7',
black = '#1a1b26',
black_transparant = '#1a1b2600',
white = '#c6c6c6',
red = "#ff757f",
skyblue = '#7aa2f7',
grey = '#3b4261',
yellow = "#ffc777",
fg_gutter = "#3b4261",
green1 = "#4fd6be",
}
local bubbles_theme = {
normal = {
a = { fg = colors.black, bg = colors.skyblue },
b = { fg = colors.white, bg = colors.grey },
c = { fg = colors.white, bg = colors.black_transparant },
},
insert = {
a = { fg = colors.black, bg = colors.blue },
b = { fg = colors.blue, bg = colors.grey },
},
visual = {
a = { fg = colors.black, bg = colors.cyan },
b = { fg = colors.cyan, bg = colors.grey },
},
replace = {
a = { bg = colors.red, fg = colors.black },
b = { bg = colors.fg_gutter, fg = colors.red },
},
command = {
a = { bg = colors.yellow, fg = colors.black },
b = { bg = colors.fg_gutter, fg = colors.yellow },
},
terminal = {
a = { bg = colors.green1, fg = colors.black },
b = { bg = colors.fg_gutter, fg = colors.green1 },
},
inactive = {
a = { fg = colors.white, bg = colors.black_transparant },
b = { fg = colors.white, bg = colors.black_transparant },
c = { fg = colors.black, bg = colors.black_transparant },
},
}
require("lualine").setup({
options = {
theme = bubbles_theme,
component_separators = "|",
section_separators = { left = "", right = "" },
disabled_filetypes = {
"TelescopePrompt",
"packer",
"alpha",
"dashboard",
"NvimTree",
"Outline",
"DressingInput",
"toggleterm",
"lazy",
"mason",
"neo-tree",
},
always_divide_middle = true,
},
sections = {
lualine_a = {
mode,
},
-- lualine_b = { "filename", "branch" },
lualine_b = { "branch" },
lualine_c = { lsp_info, diagnostics },
lualine_x = { diff, spaces, "filetype" },
lualine_y = { "progress" },
lualine_z = {
{ "location", separator = { left = "", right = "" }, left_padding = 3 },
},
},
inactive_sections = {
lualine_a = { "filename" },
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = { "location" },
},
tabline = {},
extensions = {},
})
end,
},
}
Custom Lueline Dracula Theme
return {
{
"nvim-lualine/lualine.nvim",
event = "BufWinEnter",
config = function()
local hide_in_width = function()
return vim.fn.winwidth(0) > 80
end
local icons = require("user.icons")
-- start for lsp
local list_registered_providers_names = function(filetype)
local s = require("null-ls.sources")
local available_sources = s.get_available(filetype)
local registered = {}
for _, source in ipairs(available_sources) do
for method in pairs(source.methods) do
registered[method] = registered[method] or {}
table.insert(registered[method], source.name)
end
end
return registered
end
local null_ls = require("null-ls")
-- for formatter
local list_registered = function(filetype)
local method = null_ls.methods.FORMATTING
local registered_providers = list_registered_providers_names(filetype)
return registered_providers[method] or {}
end
--- for linter
local alternative_methods = {
null_ls.methods.DIAGNOSTICS,
null_ls.methods.DIAGNOSTICS_ON_OPEN,
null_ls.methods.DIAGNOSTICS_ON_SAVE,
}
local linter_list_registered = function(filetype)
local registered_providers = list_registered_providers_names(filetype)
local providers_for_methods = vim.tbl_flatten(vim.tbl_map(function(m)
return registered_providers[m] or {}
end, alternative_methods))
return providers_for_methods
end
-- end for lsp
local lsp_info = {
function()
local msg = "LS Inactive"
local buf_ft = vim.bo.filetype
local clients = vim.lsp.get_active_clients()
-- start register
local buf_clients = vim.lsp.buf_get_clients()
local buf_client_names = {}
if next(buf_clients) == nil then
-- TODO: clean up this if statement
if type(msg) == "boolean" or #msg == 0 then
return "LS Inactive"
end
return msg
end
-- add client
for _, client in pairs(buf_clients) do
if client.name ~= "null-ls" and client.name ~= "copilot" then
table.insert(buf_client_names, client.name)
end
end
-- add formatter
local supported_formatters = list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_formatters)
-- add linter
local supported_linters = linter_list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_linters)
-- decomple
local unique_client_names = vim.fn.uniq(buf_client_names)
local msg = table.concat(unique_client_names, ", ")
return msg
end,
--icon = " ",
icon = icons.ui.Gear .. "",
padding = 1,
}
local diagnostics = {
"diagnostics",
sources = { "nvim_diagnostic" },
sections = { "error", "warn" },
-- symbols = { error = " ", warn = " " },
symbols = {
error = icons.diagnostics.BoldError .. " ",
warn = icons.diagnostics.BoldWarning .. " ",
},
colored = true,
update_in_insert = false,
always_visible = false,
}
local diff = {
"diff",
colored = true,
-- symbols = { added = " ", modified = " ", removed = " " }, -- changes diff symbols
symbols = {
added = icons.git.LineAdded .. " ",
modified = icons.git.LineModified .. " ",
removed = icons.git.LineRemoved .. " ",
}, -- changes diff symbols
cond = hide_in_width,
}
local spaces = function()
-- return " " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
return icons.ui.Tab .. " " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
end
local mode = {
"mode",
padding = 1,
separator = { left = " " },
-- right_padding = 3,
fmt = function(str)
return " " .. str
end,
}
local branch = {
"branch",
padding = 1,
}
local get_branch = function()
if vim.b.gitsigns_head ~= nil then
return " " .. vim.b.gitsigns_head
else
return "" .. vim.fn.fnamemodify("", ":t")
end
end
local lsp_progress = {}
local data_ok, lspprogress = pcall(require, "lsp-progress")
if data_ok then
lsp_progress = lspprogress.progress
end
-- stylua: ignore
local colors = {
blue = '#50fa7b',
cyan = '#f1fa8c',
black = '#1a1b26',
black_transparant = 'none',
white = '#c6c6c6',
red = "#ff757f",
skyblue_1 = '#bd93f9',
grey = '#5f6a8e',
yellow = "#ffb86c",
fg_gutter = "#3b4261",
green1 = "#bd93f9",
}
local bubbles_theme = {
normal = {
a = { fg = colors.black, bg = colors.skyblue_1 },
b = { fg = colors.white, bg = colors.grey },
c = { fg = colors.white, bg = colors.black_transparant },
},
insert = {
a = { fg = colors.black, bg = colors.blue },
b = { fg = colors.blue, bg = colors.grey },
},
visual = {
a = { fg = colors.black, bg = colors.cyan },
b = { fg = colors.cyan, bg = colors.grey },
},
replace = {
a = { bg = colors.red, fg = colors.black },
b = { bg = colors.fg_gutter, fg = colors.red },
},
command = {
a = { bg = colors.yellow, fg = colors.black },
b = { bg = colors.fg_gutter, fg = colors.yellow },
},
terminal = {
a = { bg = colors.green1, fg = colors.black },
b = { bg = colors.fg_gutter, fg = colors.green1 },
},
inactive = {
a = { fg = colors.white, bg = colors.black_transparant },
b = { fg = colors.white, bg = colors.black_transparant },
c = { fg = colors.black, bg = colors.black_transparant },
},
}
require("lualine").setup({
options = {
theme = bubbles_theme,
-- theme = "auto",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
"TelescopePrompt",
"packer",
"alpha",
"dashboard",
"NvimTree",
"Outline",
"DressingInput",
"toggleterm",
"lazy",
"mason",
"neo-tree",
"startuptime",
},
always_divide_middle = true,
},
sections = {
lualine_a = {
mode,
},
lualine_b = { get_branch },
lualine_c = { lsp_info, diagnostics, lsp_progress },
lualine_x = { diff, spaces, "filetype" },
lualine_y = { "progress" },
lualine_z = {
{ "location", separator = { right = " " }, padding = 1 },
},
},
inactive_sections = {
lualine_a = { "filename" },
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = { "location" },
},
tabline = {},
extensions = {},
})
end,
},
}
Nvim-Ufo
return {
"kevinhwang91/nvim-ufo",
dependencies = {
"kevinhwang91/promise-async",
{
"luukvbaal/statuscol.nvim",
config = function()
local builtin = require("statuscol.builtin")
require("statuscol").setup({
-- relculright = true,
-- segments = {
-- { text = { builtin.foldfunc }, click = "v:lua.ScFa" },
-- { text = { "%s" }, click = "v:lua.ScSa" },
-- { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
-- },
setopt = true,
relculright = true,
segments = {
{ text = { "%s" }, click = "v:lua.ScSa" },
{
-- text = { builtin.foldfunc, " " },
text = { builtin.foldfunc },
condition = { builtin.not_empty, true, builtin.not_empty },
click = "v:lua.ScFa",
},
{ text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" },
-- { text = { builtin.lnumfunc }, click = "v:lua.ScLa" },
},
})
end,
},
},
lazy = true,
-- event = "BufReadPost",
event = { "BufReadPost", "BufRead", "InsertEnter", "BufNewFile" },
config = function()
vim.o.foldcolumn = "1" -- '0' is not bad
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
vim.o.foldlevelstart = 99
vim.o.foldenable = true
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep:│,foldclose:]]
vim.o.fillchars = [[eob: ,fold: ,foldopen:▾,foldsep:│,foldclose:▸]]
-- vim.opt.fillchars = {
-- vert = "▕", -- alternatives │
-- fold = " ",
-- eob = " ", -- suppress ~ at EndOfBuffer
-- diff = "╱", -- alternatives = ⣿ ░ ─
-- msgsep = "‾",
-- foldopen = "▾",
-- foldsep = "│",
-- foldclose = "▸",
-- }
-- these are "extra", change them as you like
vim.keymap.set("n", "zR", require("ufo").openAllFolds)
vim.keymap.set("n", "zM", require("ufo").closeAllFolds)
vim.cmd("highlight FoldColumn guifg=" .. vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID("Comment")), "fg"))
-- vim.cmd("highlight FoldColumn guifg=" .. vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID("IblIndent")), "fg"))
-- Option 3: treesitter as a main provider instead
-- Only depend on `nvim-treesitter/queries/filetype/folds.scm`,
-- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()`
require("ufo").setup({
-- provider_selector = function(bufnr, filetype, buftype)
-- return { "treesitter", "indent" }
-- end,
open_fold_hl_timeout = 150,
preview = {
win_config = {
border = { "", "─", "", "", "", "─", "", "" },
-- winhighlight = 'Normal:Normal',
-- winhighlight = 'IncSearch:Folded',
winhighlight = "Normal:UfoPreviewNormal,FloatBorder:UfoPreviewBorder,CursorLine:UfoPreviewCursorLine",
winblend = 0,
},
mappings = {
scrollU = "<C-u>",
scrollD = "<C-d>",
jumpTop = "[",
jumpBot = "]",
},
},
provider_selector = function(_, filetype)
return { "treesitter", "indent" }
end,
fold_virt_text_handler = function(virt_text, lnum, end_lnum, width, truncate)
local result = {}
local _end = end_lnum - 1
local final_text = vim.trim(vim.api.nvim_buf_get_text(0, _end, 0, _end, -1, {})[1])
local suffix = final_text:format(end_lnum - lnum)
local suffix_width = vim.fn.strdisplaywidth(suffix)
local target_width = width - suffix_width
local cur_width = 0
for _, chunk in ipairs(virt_text) do
local chunk_text = chunk[1]
local chunk_width = vim.fn.strdisplaywidth(chunk_text)
if target_width > cur_width + chunk_width then
table.insert(result, chunk)
else
chunk_text = truncate(chunk_text, target_width - cur_width)
local hl_group = chunk[2]
table.insert(result, { chunk_text, hl_group })
chunk_width = vim.fn.strdisplaywidth(chunk_text)
-- str width returned from truncate() may less than 2nd argument, need padding
if cur_width + chunk_width < target_width then
suffix = suffix .. (" "):rep(target_width - cur_width - chunk_width)
end
break
end
cur_width = cur_width + chunk_width
end
table.insert(result, { " ⋯ ", "NonText" })
table.insert(result, { suffix, "TSPunctBracket" })
return result
end,
})
end,
}
tailwindcss-colorizer-cmp.nvim
return {
{
"NvChad/nvim-colorizer.lua",
opts = {
user_default_options = {
tailwind = true,
},
},
},
{
"hrsh7th/nvim-cmp",
dependencies = {
{ "roobert/tailwindcss-colorizer-cmp.nvim", config = true },
},
opts = function(_, opts)
-- original kind icon formatter
local format_kinds = opts.formatting.format
opts.formatting.format = function(entry, item)
format_kinds(entry, item) -- add icons
local lspkind = require("tailwindcss-colorizer-cmp").formatter(entry, item)
if lspkind.kind == "XX" then
lspkind.kind = " "
end
return lspkind
end
end,
},
}
Sumber : https://github.com/roobert/tailwindcss-colorizer-cmp.nvim
Telescope File Browser
sumber :
return {
"nvim-telescope/telescope-file-browser.nvim",
dependencies = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" },
keys = {
{
"sf",
function()
local telescope = require "telescope"
local function telescope_buffer_dir()
return vim.fn.expand "%:p:h"
end
telescope.extensions.file_browser.file_browser {
path = "%:p:h",
cwd = telescope_buffer_dir(),
respect_gitignore = false,
hidden = true,
grouped = true,
previewer = false,
initial_mode = "insert",
layout_config = { height = 40 },
}
end,
desc = "Open File Browser with the path of the current buffer",
},
},
config = function(_, opts)
local telescope = require "telescope"
local actions = require "telescope.actions"
local fb_actions = require("telescope").extensions.file_browser.actions
opts.extensions = {
file_browser = {
theme = "dropdown",
-- disables netrw and use telescope-file-browser in its place
hijack_netrw = true,
mappings = {
-- your custom insert mode mappings
["n"] = {
-- your custom normal mode mappings
["N"] = fb_actions.create,
["h"] = fb_actions.goto_parent_dir,
["<C-u>"] = function(prompt_bufnr)
for i = 1, 10 do
actions.move_selection_previous(prompt_bufnr)
end
end,
["<C-d>"] = function(prompt_bufnr)
for i = 1, 10 do
actions.move_selection_next(prompt_bufnr)
end
end,
},
},
},
}
telescope.setup(opts)
require("telescope").load_extension "file_browser"
end,
}
Refactoring
return {
-- Incremental rename
{
"smjonas/inc-rename.nvim",
cmd = "IncRename",
keys = {
{
"<leader>un",
function()
return ":IncRename " .. vim.fn.expand "<cword>"
end,
desc = "Incremental rename",
mode = "n",
noremap = true,
expr = true,
},
},
config = true,
},
-- Refactoring tool
{
"ThePrimeagen/refactoring.nvim",
keys = {
{
"<leader>r",
function()
require("refactoring").select_refactor {
show_success_message = true,
}
end,
mode = "v",
noremap = true,
silent = true,
expr = false,
},
},
opts = {},
},
}
Database Management
return {
"kristijanhusak/vim-dadbod-ui",
dependencies = {
{ "tpope/vim-dadbod", lazy = true },
{ "kristijanhusak/vim-dadbod-completion", ft = { "sql", "mysql", "plsql" }, lazy = true },
},
init = function()
-- Your DBUI configuration
vim.g.db_ui_show_database_icon = 1
vim.g.db_ui_use_nerd_fonts = 1
vim.g.db_ui_show_help = 0
end,
config = function()
local function db_completion()
require("cmp").setup.buffer {
sources = { { name = "vim-dadbod-completion" } },
}
end
vim.g.db_ui_save_location = vim.fn.stdpath "config" .. require("plenary.path").path.sep .. "db_ui"
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"sql",
},
command = [[setlocal omnifunc=vim_dadbod_completion#omni]],
})
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"sql",
"mysql",
"plsql",
},
callback = function()
vim.schedule(db_completion)
end,
})
end,
cmd = {
"DBUIToggle",
"DBUI",
"DBUIAddConnection",
"DBUIFindBuffer",
"DBUIRenameBuffer",
"DBUILastQueryInfo",
},
keys = {
{
"<leader>D",
"<cmd>NvimTreeClose<cr><cmd>tabnew<cr><bar><bar><cmd>DBUI<cr>",
},
},
}
Neotest-Jest
return {
"nvim-neotest/neotest",
dependencies = {
"nvim-neotest/neotest-jest",
"nvim-neotest/nvim-nio",
},
config = function()
require("neotest").setup {
adapters = {
require "neotest-jest" {
jestCommand = "npm test -- ",
jestConfigFile = function()
local file = vim.fn.expand "%:p"
if string.find(file, "/packages/") then
return string.match(file, "(.-/[^/]+/)src") .. "jest.config.mjs"
end
return vim.fn.getcwd() .. "/jest.config.mjs"
end,
env = { CI = true },
cwd = function()
local file = vim.fn.expand "%:p"
if string.find(file, "/packages/") then
return string.match(file, "(.-/[^/]+/)src")
end
return vim.fn.getcwd()
end,
status = { virtual_text = true },
output = { open_on_run = true },
},
},
}
end,
keys = {
{
"<leader>Tt",
function()
require("neotest").run.run(vim.fn.expand "%")
end,
desc = "Run File",
},
{
"<leader>Tr",
function()
require("neotest").run.run()
end,
desc = "Run Nearest",
},
{
"<leader>TT",
function()
require("neotest").run.run(vim.loop.cwd())
end,
desc = "Run All Test Files",
},
{
"<leader>Tl",
function()
require("neotest").run.run_last()
end,
desc = "Run Last",
},
{
"<leader>Ts",
function()
require("neotest").summary.toggle()
end,
desc = "Toggle Summary",
},
{
"<leader>To",
function()
require("neotest").output.open { enter = true, auto_close = true }
end,
desc = "Show Output",
},
{
"<leader>TO",
function()
require("neotest").output_panel.toggle()
end,
desc = "Toggle Output Panel",
},
{
"<leader>TS",
function()
require("neotest").run.stop()
end,
desc = "Stop",
},
},
}
Debuging Javascript
return {
{
"rcarriga/nvim-dap-ui",
lazy = true,
event = "BufRead",
dependencies = {
{ "mfussenegger/nvim-dap", lazy = true },
{ "nvim-neotest/nvim-nio", lazy = true },
{
"mxsdev/nvim-dap-vscode-js",
dependencies = {
"microsoft/vscode-js-debug",
version = "1.x",
build = "npm i && npm run compile vsDebugServerBundle && mv dist out",
},
config = function()
require("dap-vscode-js").setup({
-- node_path = "node", -- Path of node executable. Defaults to $NODE_PATH, and then "node"
debugger_path = vim.fn.stdpath("data") .. "/lazy/vscode-js-debug",
-- debugger_cmd = { "extension" }, -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`.
adapters = {
"chrome",
"pwa-node",
"pwa-chrome",
"pwa-msedge",
"node-terminal",
"pwa-extensionHost",
"node",
"chrome",
}, -- which adapters to register in nvim-dap
-- log_file_path = "(stdpath cache)/dap_vscode_js.log" -- Path for file logging
-- log_file_level = false -- Logging level for output to file. Set to false to disable file logging.
-- log_console_level = vim.log.levels.ERROR -- Logging level for output to console. Set to false to disable console output.
})
end,
},
},
config = function()
require("user.dapui")
local js_based_languages = { "typescript", "javascript", "typescriptreact" }
for _, language in ipairs(js_based_languages) do
require("dap").configurations[language] = {
{
type = "pwa-node",
request = "launch",
name = "Launch file",
program = "${file}",
cwd = "${workspaceFolder}",
},
{
type = "pwa-node",
request = "attach",
name = "Attach",
processId = require("dap.utils").pick_process,
cwd = "${workspaceFolder}",
},
{
type = "pwa-chrome",
request = "launch",
name = 'Start Chrome with "localhost"',
url = "http://localhost:3000",
webRoot = "${workspaceFolder}",
userDataDir = "${workspaceFolder}/.vscode/vscode-chrome-debug-userdatadir",
},
}
end
end,
},
}
Conformm Config
return {
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
opts = function()
local mason_reg = require("mason-registry")
local formatters = {}
local formatters_by_ft = {}
-- add diff langue vs filetype
local keymap = {
["c++"] = "cpp",
["c#"] = "cs",
}
-- add dif conform vs mason
local name_map = {
["cmakelang"] = "cmake_format",
["deno"] = "deno_fmt",
["elm-format"] = "elm_format",
["gdtoolkit"] = "gdformat",
["nixpkgs-fmt"] = "nixpkgs_fmt",
["opa"] = "opa_fmt",
["php-cs-fixer"] = "php_cs_fixer",
["ruff"] = "ruff_format",
["sql-formatter"] = "sql_formatter",
["xmlformatter"] = "xmlformat",
}
for _, pkg in pairs(mason_reg.get_installed_packages()) do
for _, type in pairs(pkg.spec.categories) do
-- only act upon a formatter
if type == "Formatter" then
-- if formatter doesn't have a builtin config, create our own from a generic template
if not require("conform").get_formatter_config(pkg.spec.name) then
-- the key of the entry to this table
-- is the name of the bare executable
-- the actual value may not be the absolute path
-- in some cases
local bin = next(pkg.spec.bin)
-- this should be replaced by a function
-- that quieries the configured mason install path
local prefix = vim.fn.stdpath("data") .. "/mason/bin/"
formatters[pkg.spec.name] = {
command = prefix .. bin,
args = { "$FILENAME" },
stdin = true,
require_cwd = false,
}
end
-- finally add the formatter to it's compatible filetype(s)
for _, ft in pairs(pkg.spec.languages) do
local ftl = string.lower(ft)
local ready = mason_reg.get_package(pkg.spec.name):is_installed()
if ready then
if keymap[ftl] ~= nil then
ftl = keymap[ftl]
end
if name_map[pkg.spec.name] ~= nil then
pkg.spec.name = name_map[pkg.spec.name]
end
formatters_by_ft[ftl] = formatters_by_ft[ftl] or {}
table.insert(formatters_by_ft[ftl], pkg.spec.name)
end
end
end
end
end
return {
format_on_save = {
lsp_fallback = true,
timeout_ms = 500,
},
formatters = formatters,
formatters_by_ft = formatters_by_ft,
}
end,
config = function(_, opts)
local conform = require("conform")
conform.setup(opts)
vim.keymap.set({ "n", "v" }, "<leader>lF", function()
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 500,
})
end, { desc = "Format file or range (in visual mode)" })
end,
}
Custem Config Nvim-lint
return {
"mfussenegger/nvim-lint",
enabled = pcode.disable_null_ls or false,
event = { "BufReadPre", "BufNewFile" },
opts = function(_, opts)
local mason_reg = require("mason-registry")
opts.linters_by_ft = opts.linters_by_ft or {}
-- add diff langue vs filetype
local keymap = {
["c++"] = "cpp",
["c#"] = "cs",
}
-- add dif conform vs mason
local name_map = {
["actionlint"] = "actionlint",
["ansible_lint"] = "ansible_lint",
["buf"] = "buf_lint",
["buildifier"] = "buildifier",
["cfn-lint"] = "cfn_lint",
["checkstyle"] = "checkstyle",
["clj-kondo"] = "clj_kondo",
["cmakelint"] = "cmakelint",
["codespell"] = "codespell",
["cpplint"] = "cpplint",
["cspell"] = "cspell",
["curlylint"] = "curlylint",
["djlint"] = "djlint",
["erb-lint"] = "erb_lint",
["eslint_d"] = "eslint_d",
["flake8"] = "flake8",
["gdtoolkit"] = "gdlint",
["golangci-lint"] = "golangcilint",
["hadolint"] = "hadolint",
["jsonlint"] = "jsonlint",
["ktlint"] = "ktlint",
["luacheck"] = "luacheck",
["markdownlint"] = "markdownlint",
["mypy"] = "mypy",
["phpcs"] = "phpcs",
["phpmd"] = "phpmd",
["phpstan"] = "phpstan",
["proselint"] = "proselint",
["pydocstyle"] = "pydocstyle",
["pylint"] = "pylint",
["revive"] = "revive",
["rstcheck"] = "rstcheck",
["rubocop"] = "rubocop",
["ruff"] = "ruff",
["selene"] = "selene",
["shellcheck"] = "shellcheck",
["sqlfluff"] = "sqlfluff",
["standardrb"] = "standardrb",
["stylelint"] = "stylelint",
["solhint"] = "solhint",
["tflint"] = "tflint",
["tfsec"] = "tfsec",
["trivy"] = "trivy",
["vale"] = "vale",
["vint"] = "vint",
["vulture"] = "vulture",
["yamllint"] = "yamllint",
}
for _, pkg in pairs(mason_reg.get_installed_packages()) do
for _, type in pairs(pkg.spec.categories) do
-- only act upon a formatter
if type == "Linter" then
-- finally add the formatter to it's compatible filetype(s)
for _, ft in pairs(pkg.spec.languages) do
local ftl = string.lower(ft)
local ready = mason_reg.get_package(pkg.spec.name):is_installed()
if ready then
if keymap[ftl] ~= nil then
ftl = keymap[ftl]
end
if name_map[pkg.spec.name] ~= nil then
pkg.spec.name = name_map[pkg.spec.name]
end
opts.linters_by_ft[ftl] = opts.linters_by_ft[ftl] or {}
table.insert(opts.linters_by_ft[ftl], pkg.spec.name)
end
end
end
end
end
end,
config = function(_, opts)
require("lint").linters_by_ft = opts.linters_by_ft
end,
}