initial commit
This commit is contained in:
commit
36f68238e8
27 changed files with 885 additions and 0 deletions
43
.gitignore
vendored
Normal file
43
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Compiled Lua sources
|
||||
luac.out
|
||||
|
||||
# luarocks build files
|
||||
*.src.rock
|
||||
*.zip
|
||||
*.tar.gz
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.os
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
*.def
|
||||
*.exp
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
|
||||
plugin/packer_compiled.lua
|
||||
101
init.lua
Normal file
101
init.lua
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
-- -- Load user configuration files
|
||||
require("user.options")
|
||||
require("user.keymaps")
|
||||
require("user.cmp")
|
||||
require("user.java")
|
||||
require("user.autopairs")
|
||||
require("user.telescope")
|
||||
require("user.gruvbox")
|
||||
require("user.lsp")
|
||||
require("user.java")
|
||||
require("user.treesitter")
|
||||
require("user.null-ls") -- Load null-ls configuration
|
||||
require("user.terminal")
|
||||
require("user.markdown")
|
||||
require("user.autocmds")
|
||||
require("user.files_utils")
|
||||
require("user.commands")
|
||||
require("user.comment")
|
||||
|
||||
return require("packer").startup(function(use)
|
||||
-- Let packer manage itself
|
||||
use("wbthomason/packer.nvim")
|
||||
|
||||
-- Completion framework
|
||||
use("hrsh7th/nvim-cmp")
|
||||
use("hrsh7th/cmp-buffer")
|
||||
use("hrsh7th/cmp-path")
|
||||
use("hrsh7th/cmp-nvim-lsp")
|
||||
use("hrsh7th/cmp-nvim-lua")
|
||||
use("saadparwaiz1/cmp_luasnip")
|
||||
use("L3MON4D3/LuaSnip")
|
||||
|
||||
-- Load test plugin configuration
|
||||
require("user.test")(use)
|
||||
|
||||
-- NERDTree plugin
|
||||
use("preservim/nerdtree")
|
||||
|
||||
-- Plugin for integrating formatters/linters
|
||||
use("jose-elias-alvarez/null-ls.nvim")
|
||||
|
||||
-- -- TS Server
|
||||
use("jose-elias-alvarez/nvim-lsp-ts-utils")
|
||||
|
||||
-- Treesitter
|
||||
use("nvim-treesitter/nvim-treesitter")
|
||||
|
||||
-- Auto pairs
|
||||
use("windwp/nvim-autopairs")
|
||||
|
||||
-- LSP Configuration
|
||||
use("neovim/nvim-lspconfig")
|
||||
|
||||
-- Java Language Server support
|
||||
use("mfussenegger/nvim-jdtls")
|
||||
|
||||
-- Markdown Preview (optional)
|
||||
use({ "iamcco/markdown-preview.nvim", run = "cd app && npm install" })
|
||||
|
||||
use({
|
||||
"nvim-telescope/telescope.nvim",
|
||||
tag = "0.1.8",
|
||||
-- or , branch = '0.1.x',
|
||||
requires = { { "nvim-lua/plenary.nvim" } },
|
||||
})
|
||||
|
||||
-- Comment
|
||||
use 'numToStr/Comment.nvim'
|
||||
|
||||
|
||||
-- Telescope FZF native
|
||||
use({
|
||||
"nvim-telescope/telescope-fzf-native.nvim",
|
||||
run = "make",
|
||||
})
|
||||
|
||||
use({ "ellisonleao/gruvbox.nvim" })
|
||||
|
||||
use({
|
||||
"williamboman/mason.nvim",
|
||||
config = function()
|
||||
require("mason").setup()
|
||||
end,
|
||||
})
|
||||
|
||||
-- Mason LSPConfig for integrating Mason with nvim-lspconfig
|
||||
use({
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
config = function()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"pyright",
|
||||
"ts_ls",
|
||||
"jdtls",
|
||||
"marksman",
|
||||
"kotlin_language_server",
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
end)
|
||||
BIN
jars/google-java-format.jar
Normal file
BIN
jars/google-java-format.jar
Normal file
Binary file not shown.
20
lua/user/autocmds.lua
Normal file
20
lua/user/autocmds.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
-- lua/user/autocmds.lua
|
||||
-- Configuration for markdown-preview.nvim
|
||||
|
||||
vim.g.mkdp_auto_start = 0
|
||||
vim.g.mkdp_auto_close = 1
|
||||
|
||||
-- Enable formatting on save for multiple file types
|
||||
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||
pattern = "*", -- Apply this to all filetypes
|
||||
callback = function()
|
||||
-- save current position
|
||||
local pos = vim.api.nvim_win_get_cursor(0)
|
||||
|
||||
-- strip trailing whitespace (essentially this strips comments that are at the end of lines)
|
||||
vim.cmd([[%s/\s\+$//e]])
|
||||
|
||||
-- restore cursor position
|
||||
vim.api.nvim_win_set_cursor(0, pos)
|
||||
end
|
||||
})
|
||||
22
lua/user/autopairs.lua
Normal file
22
lua/user/autopairs.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
-- lua/user/autopairs.lua
|
||||
require('nvim-autopairs').setup{
|
||||
disable_filetype = { "TelescopePrompt", "vim" },
|
||||
check_ts = true, -- Enable Treesitter integration
|
||||
ts_config = {
|
||||
lua = { "string" }, -- Disable auto-pairs inside Lua strings
|
||||
javascript = { "template_string" },
|
||||
java = false, -- Disable Treesitter integration for Java
|
||||
},
|
||||
fast_wrap = {
|
||||
map = '<M-e>', -- Trigger fast wrap with Alt+e
|
||||
chars = { '{', '[', '(', '"', "'" },
|
||||
pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], '%s+', ''),
|
||||
offset = 0, -- Offset from pattern match
|
||||
end_key = '$',
|
||||
keys = 'qwertyuiopzxcvbnmasdfghjkl',
|
||||
check_comma = true,
|
||||
highlight = 'Search',
|
||||
highlight_grey='Comment'
|
||||
},
|
||||
}
|
||||
|
||||
48
lua/user/cmp.lua
Normal file
48
lua/user/cmp.lua
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
-- ~/.config/nvim/lua/user/cmp.lua
|
||||
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
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(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Confirm selection with Enter
|
||||
|
||||
-- Tab to navigate forward through completion menu
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif require("luasnip").expand_or_jumpable() then
|
||||
require("luasnip").expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
-- Shift-Tab to navigate backward through completion menu
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif require("luasnip").jumpable(-1) then
|
||||
require("luasnip").jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" }, -- Snippet support
|
||||
}, {
|
||||
{ name = "buffer" }, -- Buffer as a fallback source
|
||||
}),
|
||||
})
|
||||
|
||||
-- Ensure that capabilities are extended for LSP
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
11
lua/user/commands.lua
Normal file
11
lua/user/commands.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
-- lua/user/commands.lua
|
||||
|
||||
-- Define user command for file creation
|
||||
vim.api.nvim_create_user_command("CreateFile", function(opts)
|
||||
local filename = opts.args
|
||||
if filename and filename ~= "" then
|
||||
require("user.files_utils").create_file(filename)
|
||||
else
|
||||
print("Please provide a filename.")
|
||||
end
|
||||
end, { nargs = 1, complete = "file" })
|
||||
17
lua/user/comment.lua
Normal file
17
lua/user/comment.lua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
-- ~/.config/nvim/lua/user/comment.lua
|
||||
local status_ok, comment = pcall(require, "Comment")
|
||||
if not status_ok then
|
||||
vim.notify("Comment.nvim not found!")
|
||||
return
|
||||
end
|
||||
|
||||
require("Comment").setup({
|
||||
toggler = {
|
||||
line = "<leader>k", -- Mapping for toggling comments
|
||||
block = "<leader>b", -- Mapping for block comments
|
||||
},
|
||||
opleader = {
|
||||
line = "<leader>k", -- Mapping for operator-pending comments
|
||||
block = "<leader>b", -- Mapping for block comments in operator-pending mode
|
||||
},
|
||||
})
|
||||
15
lua/user/files_utils.lua
Normal file
15
lua/user/files_utils.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
-- lua/user/files_utils.lua
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.create_file(filename)
|
||||
local file = io.open(filename, "w")
|
||||
if file then
|
||||
file:close()
|
||||
print("File created: " .. filename)
|
||||
else
|
||||
print("Failed to create file: " .. filename)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
26
lua/user/gruvbox.lua
Normal file
26
lua/user/gruvbox.lua
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
-- Default options:
|
||||
require("gruvbox").setup({
|
||||
terminal_colors = true, -- add neovim terminal colors
|
||||
undercurl = true,
|
||||
underline = true,
|
||||
bold = true,
|
||||
italic = {
|
||||
strings = true,
|
||||
emphasis = true,
|
||||
comments = true,
|
||||
operators = false,
|
||||
folds = true,
|
||||
},
|
||||
strikethrough = true,
|
||||
invert_selection = false,
|
||||
invert_signs = false,
|
||||
invert_tabline = false,
|
||||
invert_intend_guides = false,
|
||||
inverse = true, -- invert background for search, diffs, statuslines and errors
|
||||
contrast = "", -- can be "hard", "soft" or empty string
|
||||
palette_overrides = {},
|
||||
overrides = {},
|
||||
dim_inactive = false,
|
||||
transparent_mode = false,
|
||||
})
|
||||
vim.cmd("colorscheme gruvbox")
|
||||
7
lua/user/java.lua
Normal file
7
lua/user/java.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- ~/.config/nvim/lua/user/java.lua
|
||||
|
||||
-- Additional Java-specific configurations can go here
|
||||
|
||||
-- For example, setting up Java-specific keybindings:
|
||||
vim.api.nvim_set_keymap('n', '<leader>oi', '<cmd>lua vim.lsp.buf.organize_imports()<CR>', { noremap = true, silent = true })
|
||||
|
||||
120
lua/user/keymaps.lua
Normal file
120
lua/user/keymaps.lua
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
local map = vim.api.nvim_set_keymap
|
||||
local default_opts = { noremap = true, silent = true }
|
||||
local search_replace = require("user.search_replace")
|
||||
|
||||
|
||||
-- Leader key
|
||||
vim.g.mapleader = " " -- Set Space as leader key
|
||||
|
||||
-- Keybinding to format the current buffer
|
||||
vim.api.nvim_set_keymap('n', '<leader>f', ':lua vim.lsp.buf.format({ async = true })<CR>', { noremap = true, silent = true })
|
||||
|
||||
-- Save file
|
||||
map("n", "<leader>w", ":w<CR>", default_opts)
|
||||
|
||||
-- Quit
|
||||
map("n", "<leader>q", ":q<CR>", default_opts)
|
||||
|
||||
-- Close current buffer
|
||||
map("n", "<leader>c", ":bd<CR>", default_opts)
|
||||
|
||||
-- save all buffers and close all but this one
|
||||
map("n", "<leader>bc", ":%bufdo w|%bd|e#<CR>", default_opts)
|
||||
|
||||
-- Toggle NERDTree
|
||||
map("n", "<leader>n", ":NERDTreeToggle<CR>", default_opts)
|
||||
|
||||
--split
|
||||
map("n", "<leader>v", ":vs<CR>", default_opts)
|
||||
map("n", "<leader>h", ":sp<CR>", default_opts)
|
||||
|
||||
-- move to end of line
|
||||
map("n", "e", "$", default_opts)
|
||||
|
||||
-- move to the starting of lin
|
||||
map("n", "s", "_", default_opts)
|
||||
|
||||
-- Move between windows
|
||||
map("n", "<C-h>", "<C-w>h", default_opts)
|
||||
map("n", "<C-j>", "<C-w>j", default_opts)
|
||||
map("n", "<C-k>", "<C-w>k", default_opts)
|
||||
map("n", "<C-l>", "<C-w>l", default_opts)
|
||||
|
||||
-- Resize windows with arrow keys
|
||||
map("n", "<C-Up>", ":resize -2<CR>", default_opts)
|
||||
map("n", "<C-Down>", ":resize +2<CR>", default_opts)
|
||||
map("n", "<C-Left>", ":vertical resize -2<CR>", default_opts)
|
||||
map("n", "<C-Right>", ":vertical resize +2<CR>", default_opts)
|
||||
|
||||
-- Copy to system clipboard
|
||||
map("v", "<leader>y", '"+y', default_opts)
|
||||
|
||||
-- Paste from system clipboard
|
||||
map("n", "<leader>p", '"+p', default_opts)
|
||||
map("v", "<leader>p", '"+p', default_opts)
|
||||
|
||||
-- Clear search highlighting
|
||||
map("n", "<leader>/", ":nohlsearch<CR>", default_opts)
|
||||
|
||||
-- Telescope keybindings
|
||||
map("n", "<leader>ff", "<cmd>Telescope find_files<CR>", default_opts) -- Find files
|
||||
map("n", "<leader>fg", "<cmd>Telescope live_grep<CR>", default_opts) -- Live grep
|
||||
map("n", "<leader>fb", "<cmd>Telescope buffers<CR>", default_opts) -- List buffers
|
||||
map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>", default_opts) -- Help tags
|
||||
|
||||
-- Keymap to invoke the LSP rename function
|
||||
map("n", "<leader>rn", ":lua vim.lsp.buf.rename()<CR>", { noremap = true, silent = true })
|
||||
|
||||
-- Go to definition
|
||||
map("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", default_opts)
|
||||
|
||||
-- Go back to previous location
|
||||
map("n", "cb", "<C-o>", default_opts) -- Map <leader>cb to go back
|
||||
|
||||
-- move forwaed to the location from which go back is triggered
|
||||
map("n", "cf", "<C-i>", default_opts)
|
||||
|
||||
--test keybindings
|
||||
map("n", "tn", ":TestNearest<CR>", default_opts)
|
||||
map("n", "tf", ":TestFile<CR>", default_opts)
|
||||
map("n", "ts", ":TestSuite<CR>", default_opts)
|
||||
map("n", "tl", ":TestLast<CR>", default_opts)
|
||||
map("n", "tv", ":TestVisit<CR>", default_opts)
|
||||
|
||||
-- code_action
|
||||
map("n", "<leader>a", ":lua vim.lsp.buf.code_action()<CR>", default_opts)
|
||||
|
||||
-- Toggle terminal
|
||||
map("n", "<leader>t", ":lua ToggleTerm()<CR>", default_opts)
|
||||
-- Close terminal with <leader>t while in terminal mode
|
||||
map("t", "<leader>t", "<C-\\><C-n>:lua ToggleTerm()<CR>", { noremap = true, silent = true })
|
||||
|
||||
-- Key bindings for Markdown preview
|
||||
map("n", "<leader>mp", ":MarkdownPreview<CR>", { noremap = true, silent = true })
|
||||
map("n", "<leader>ms", ":MarkdownPreviewStop<CR>", { noremap = true, silent = true })
|
||||
map("n", "<leader>mf", ":MarkdownPreviewFollow<CR>", { noremap = true, silent = true })
|
||||
|
||||
-- Optional: Key binding to toggle Markdown preview
|
||||
map("n", "<leader>mt", ":call ToggleMarkdownPreview()<CR>", { noremap = true, silent = true })
|
||||
|
||||
-- java at key binding
|
||||
map("n", "<leader>jf", ":lua vim.lsp.buf.at()<CR>", { noremap = true, silent = true })
|
||||
|
||||
-- search and replace function
|
||||
map("n", "<leader>sr", ':lua require("user.search_replace").search_replace()<CR>', { noremap = true, silent = true })
|
||||
|
||||
-- Key mapping to trigger LSP rename
|
||||
vim.api.nvim_set_keymap("n", "<leader>rn", ":lua vim.lsp.buf.rename()<CR>", { noremap = true, silent = true })
|
||||
|
||||
-- In init.lua or lua/user/keymaps.lua
|
||||
vim.api.nvim_set_keymap(
|
||||
"n",
|
||||
"<Leader>cf",
|
||||
":lua require('user.files_utils').create_file('NewFile.java')<CR>",
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
|
||||
map("n", "<leader>d", ":lua vim.lsp.buf.hover()<CR>", { silent = true })
|
||||
|
||||
|
||||
|
||||
12
lua/user/lsp.lua
Normal file
12
lua/user/lsp.lua
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- Load language server configuration
|
||||
require("user.lsp_servers.pyright")
|
||||
require("user.lsp_servers.ts_ls")
|
||||
require("user.lsp_servers.jdtls")
|
||||
require("user.lsp_servers.marksman")
|
||||
require("user.lsp_servers.kotlin_ls")
|
||||
|
||||
-- Mason setup
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = { "pyright", "ts_ls", "jdtls", "marksman", "kotlin_language_server" }, -- Ensure Kotlin LSP is installed
|
||||
})
|
||||
72
lua/user/lsp_servers/jdtls.lua
Normal file
72
lua/user/lsp_servers/jdtls.lua
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
lspconfig.jdtls.setup({
|
||||
cmd = {
|
||||
"/home/prabhat/.local/share/nvim/mason/packages/jdtls/bin/jdtls",
|
||||
"-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",
|
||||
"-Xmx1G",
|
||||
"-Xms100m",
|
||||
"--add-modules=ALL-SYSTEM",
|
||||
"--add-opens",
|
||||
"java.base/java.util=ALL-UNNAMED",
|
||||
"--add-opens",
|
||||
"java.base/java.lang=ALL-UNNAMED",
|
||||
"-jar",
|
||||
"/home/prabhat/.local/share/nvim/mason/packages/jdtls/plugins/org.eclipse.equinox.launcher_*.jar",
|
||||
"-configuration",
|
||||
"/home/prabhat/.local/share/nvim/mason/packages/jdtls/config_linux",
|
||||
"-data",
|
||||
"/home/prabhat/.local/share/nvim/jdtls-workspace",
|
||||
},
|
||||
capabilities = capabilities,
|
||||
root_dir = function()
|
||||
return vim.fs.dirname(
|
||||
vim.fs.find({ ".git", "mvnw", "gradlew", "pom.xml", "build.gradle" }, { upward = true })[1]
|
||||
)
|
||||
end,
|
||||
settings = {
|
||||
java = {
|
||||
completion = {
|
||||
favoriteStaticMembers = {
|
||||
"org.junit.jupiter.api.Assertions.*",
|
||||
"org.mockito.Mockito.*",
|
||||
"java.util.Objects.requireNonNull",
|
||||
"java.util.Objects.requireNonNullElse",
|
||||
},
|
||||
filteredTypes = {
|
||||
"com.sun.*",
|
||||
"io.micrometer.shaded.*",
|
||||
"java.awt.*",
|
||||
"jdk.*",
|
||||
"sun.*",
|
||||
},
|
||||
},
|
||||
import = {
|
||||
exclusions = {
|
||||
"**/internal/**",
|
||||
},
|
||||
maven = {
|
||||
enabled = true,
|
||||
downloadSources = true,
|
||||
},
|
||||
gradle = {
|
||||
enabled = true,
|
||||
},
|
||||
settings = {
|
||||
-- Customize import order
|
||||
importOrder = {
|
||||
"java",
|
||||
"javax",
|
||||
"org",
|
||||
"com",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
28
lua/user/lsp_servers/kotlin_ls.lua
Normal file
28
lua/user/lsp_servers/kotlin_ls.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
-- lua/user/lsp_servers/kotlin_ls.lua
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
-- Setup the Kotlin language server
|
||||
lspconfig.kotlin_language_server.setup({
|
||||
cmd = { "kotlin-language-server" }, -- The command to start the server
|
||||
on_attach = function(client, bufnr)
|
||||
-- Key mappings for LSP functions
|
||||
local opts = { noremap = true, silent = true }
|
||||
local function buf_set_keymap(...)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
end
|
||||
|
||||
buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
buf_set_keymap("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||
buf_set_keymap("n", "<leader>rn", "<Cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
end,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
settings = {
|
||||
kotlin = {
|
||||
linting = { enabled = true },
|
||||
completion = { enabled = true },
|
||||
},
|
||||
},
|
||||
})
|
||||
6
lua/user/lsp_servers/marksman.lua
Normal file
6
lua/user/lsp_servers/marksman.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
-- Setup for Markdown LSP (Marksman)
|
||||
lspconfig.marksman.setup({
|
||||
-- Add additional settings here
|
||||
filetypes = { "markdown", "md" },
|
||||
})
|
||||
15
lua/user/lsp_servers/pyright.lua
Normal file
15
lua/user/lsp_servers/pyright.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
|
||||
lspconfig.pyright.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
-- Custom keymaps and commands for pyright
|
||||
end,
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
useLibraryCodeForTypes = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
41
lua/user/lsp_servers/ts_ls.lua
Normal file
41
lua/user/lsp_servers/ts_ls.lua
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
local lspconfig = require("lspconfig")
|
||||
|
||||
lspconfig.ts_ls.setup({
|
||||
on_attach = function(client, bufnr)
|
||||
-- Custom keymaps and commands for tsserver
|
||||
local opts = { noremap = true, silent = true }
|
||||
-- Example key mappings
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>rn", "<Cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
end,
|
||||
filetypes = {
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"typescript.tsx",
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"javascript.jsx",
|
||||
},
|
||||
cmd = { "typescript-language-server", "--stdio" },
|
||||
root_dir = lspconfig.util.root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"),
|
||||
settings = {
|
||||
-- Enable document formatting
|
||||
format = {
|
||||
enable = true,
|
||||
insertSpaceAfterCommaDelimiter = true,
|
||||
insertSpaceAfterSemicolon = true,
|
||||
insertSpaceBeforeAndAfterOperator = true,
|
||||
indentStyle = "smart",
|
||||
indentSize = 2,
|
||||
wrapLineLength = 120,
|
||||
},
|
||||
-- Diagnostics and completion settings
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
},
|
||||
completions = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
10
lua/user/markdown.lua
Normal file
10
lua/user/markdown.lua
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
-- Define function to toggle Markdown preview
|
||||
|
||||
vim.cmd([[
|
||||
function! StopMarkdownPreview()
|
||||
if exists('g:mkdp_is_ready') && g:mkdp_is_ready
|
||||
let g:mkdp_auto_start = 0
|
||||
call mkdp#stop()
|
||||
endif
|
||||
endfunction
|
||||
]])
|
||||
38
lua/user/null-ls.lua
Normal file
38
lua/user/null-ls.lua
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
-- File: lua/user/null-ls.lua
|
||||
|
||||
local null_ls = require("null-ls")
|
||||
|
||||
-- Define builtins for formatting
|
||||
local formatting = null_ls.builtins.formatting
|
||||
|
||||
-- Configure null-ls
|
||||
local sources = {
|
||||
formatting.prettier, -- Use prettier for formatting (JavaScript, TypeScript, etc.)
|
||||
formatting.black, -- Use black for Python formatting
|
||||
formatting.stylua, -- Use stylua for Lua formatting
|
||||
formatting.google_java_format.with({
|
||||
command = "java",
|
||||
args = { "-jar", "/home/prabhat/.config/nvim/jars/google-java-format.jar", "-" },
|
||||
extra_args = { "--aosp" }, -- optional: use AOSP style formatting
|
||||
--command = "google-java-format", -- specify command if not in PATH
|
||||
}),
|
||||
-- Add other formatters based on your needs
|
||||
}
|
||||
|
||||
null_ls.setup({
|
||||
sources = sources,
|
||||
on_attach = function(client, bufnr)
|
||||
if client.server_capabilities.documentFormattingProvider then
|
||||
local lsp_format_group = vim.api.nvim_create_augroup("LspFormatting", { clear = true })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = lsp_format_group,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local view = vim.fn.winsaveview()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
vim.fn.winrestview(view)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
67
lua/user/options.lua
Normal file
67
lua/user/options.lua
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
local opt = vim.opt
|
||||
|
||||
-- Line numbers
|
||||
opt.number = true
|
||||
opt.relativenumber = true
|
||||
|
||||
-- Tabs and indentation
|
||||
opt.expandtab = true
|
||||
opt.tabstop = 4
|
||||
opt.shiftwidth = 4
|
||||
opt.smartindent = true
|
||||
|
||||
-- Disable swapfile
|
||||
opt.swapfile = false
|
||||
|
||||
-- Enable mouse support
|
||||
opt.mouse = "a" -- put "a" to enable in all mode or "n" to enable on normal mode
|
||||
|
||||
-- Enable clipboard access
|
||||
opt.clipboard = "unnamedplus"
|
||||
|
||||
-- Case insensitive searching unless /C or capital in search
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
|
||||
-- Appearance
|
||||
opt.termguicolors = true
|
||||
opt.background = "dark"
|
||||
|
||||
-- creates backup files
|
||||
opt.backup = false
|
||||
|
||||
-- allows neovim to access the system clipboard
|
||||
opt.clipboard = "unnamedplus"
|
||||
|
||||
-- more space in the neovim command line for displaying messages
|
||||
opt.cmdheight = 2
|
||||
|
||||
-- highlight all matches on previous search pattern
|
||||
opt.hlsearch = true
|
||||
|
||||
-- enable persistent undo
|
||||
opt.undofile = true
|
||||
|
||||
-- faster completion (4000ms default)
|
||||
opt.updatetime = 300
|
||||
|
||||
-- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
|
||||
opt.writebackup = false
|
||||
|
||||
-- highlight the current Line
|
||||
opt.cursorline = true
|
||||
|
||||
-- always show the sign column, otherwise it would shift the text each time
|
||||
opt.signcolumn = "yes"
|
||||
|
||||
-- display lines as one long line
|
||||
opt.wrap = true
|
||||
|
||||
-- companion to wrap, don't split words
|
||||
opt.linebreak = true
|
||||
|
||||
-- minimal number of screen lines to keep above and below the cursor
|
||||
opt.scrolloff = 8
|
||||
|
||||
-- minimal number of screen columns either side of cursor if wrap is `false`
|
||||
opt.sidescrolloff = 8
|
||||
14
lua/user/search_replace.lua
Normal file
14
lua/user/search_replace.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
-- lua/user/search_replace.lua
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.search_replace()
|
||||
-- Prompt for the old name
|
||||
local old_name = vim.fn.input("Old name: ")
|
||||
-- Prompt for the new name
|
||||
local new_name = vim.fn.input("New name: ")
|
||||
-- Execute the search and replace command
|
||||
vim.cmd(string.format("%%s/%s/%s/g", old_name, new_name))
|
||||
end
|
||||
|
||||
return M
|
||||
16
lua/user/snippets.lua
Normal file
16
lua/user/snippets.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
-- lua/user/snippets.lua
|
||||
local ls = require('luasnip')
|
||||
|
||||
ls.add_snippets('lua', {
|
||||
ls.snippet('func', {
|
||||
ls.text_node('function '),
|
||||
ls.insert_node(1, 'name'),
|
||||
ls.text_node('('),
|
||||
ls.insert_node(2),
|
||||
ls.text_node(')'),
|
||||
ls.text_node(' '),
|
||||
ls.insert_node(0),
|
||||
ls.text_node('end'),
|
||||
}),
|
||||
})
|
||||
|
||||
59
lua/user/telescope.lua
Normal file
59
lua/user/telescope.lua
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
-- lua/user/telescope.lua
|
||||
|
||||
local telescope = require('telescope')
|
||||
local actions = require('telescope.actions')
|
||||
|
||||
telescope.setup{
|
||||
defaults = {
|
||||
prompt_prefix = "> ",
|
||||
selection_caret = "> ",
|
||||
entry_prefix = " ",
|
||||
initial_mode = "insert",
|
||||
layout_strategy = "horizontal", -- Set layout strategy to vertical
|
||||
layout_config = {
|
||||
vertical = {
|
||||
mirror = false,
|
||||
preview_height = 0.6, -- Adjust this value for preview height
|
||||
prompt_position = "top",
|
||||
width = 0.75, -- Adjust the width of the preview window
|
||||
},
|
||||
horizontal = {
|
||||
mirror = false,
|
||||
preview_width = 0.6, -- Adjust this value for preview width
|
||||
},
|
||||
},
|
||||
sorting_strategy = "ascending",
|
||||
file_sorter = require('telescope.sorters').get_fzy_sorter,
|
||||
file_ignore_patterns = {},
|
||||
generic_sorter = require('telescope.sorters').get_generic_fuzzy_sorter,
|
||||
path_display = { "truncate" },
|
||||
winblend = 0,
|
||||
border = {},
|
||||
borderchars = {
|
||||
'─', '│', '─', '│',
|
||||
'┼', '│', '┤', '│'
|
||||
},
|
||||
color_devicons = true,
|
||||
use_less = true,
|
||||
set_env = { ['COLORTERM'] = 'truecolor' },
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-u>"] = false,
|
||||
["<C-d>"] = actions.delete_buffer,
|
||||
["<C-n>"] = actions.move_selection_next,
|
||||
["<C-p>"] = actions.move_selection_previous,
|
||||
["<C-c>"] = actions.close,
|
||||
},
|
||||
n = {
|
||||
["<C-d>"] = actions.delete_buffer,
|
||||
["<C-n>"] = actions.move_selection_next,
|
||||
["<C-p>"] = actions.move_selection_previous,
|
||||
["<C-c>"] = actions.close,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
-- Load fzf extension
|
||||
require('telescope').load_extension('fzf')
|
||||
|
||||
26
lua/user/terminal.lua
Normal file
26
lua/user/terminal.lua
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
-- Define the ToggleTerm function globally
|
||||
function _G.ToggleTerm()
|
||||
-- Check if there is a terminal buffer open
|
||||
local term_buf = nil
|
||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||
if vim.api.nvim_buf_get_option(buf, "buftype") == "terminal" then
|
||||
term_buf = buf
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if term_buf then
|
||||
-- If terminal buffer is open, find its window
|
||||
local term_win = vim.fn.bufwinnr(term_buf)
|
||||
if term_win ~= -1 then
|
||||
-- If terminal window is open, close it
|
||||
vim.cmd(term_win .. "close")
|
||||
else
|
||||
-- If terminal buffer exists but window is not open, open it in a split
|
||||
vim.cmd("belowright split | buffer " .. term_buf)
|
||||
end
|
||||
else
|
||||
-- No terminal buffer found, open a new one
|
||||
vim.cmd("belowright split | terminal")
|
||||
end
|
||||
end
|
||||
18
lua/user/test.lua
Normal file
18
lua/user/test.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
-- lua/user/test.lua
|
||||
return function()
|
||||
-- Set up vim-test plugin
|
||||
require("packer").use({
|
||||
"vim-test/vim-test",
|
||||
config = function()
|
||||
vim.cmd([[
|
||||
let test#strategy = "neovim"
|
||||
" Customize the keybindings or other settings here
|
||||
nmap <silent> t<C-n> :TestNearest<CR>
|
||||
nmap <silent> t<C-f> :TestFile<CR>
|
||||
nmap <silent> t<C-s> :TestSuite<CR>
|
||||
nmap <silent> t<C-l> :TestLast<CR>
|
||||
nmap <silent> t<C-g> :TestVisit<CR>
|
||||
]])
|
||||
end,
|
||||
})
|
||||
end
|
||||
33
lua/user/treesitter.lua
Normal file
33
lua/user/treesitter.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"lua",
|
||||
"python",
|
||||
"java",
|
||||
"c",
|
||||
"cpp",
|
||||
"javascript",
|
||||
"kotlin",
|
||||
"go",
|
||||
},
|
||||
highlight = {
|
||||
enable = true,
|
||||
use_language_tree = true,
|
||||
},
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
},
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
},
|
||||
autopairs = {
|
||||
enable = true,
|
||||
},
|
||||
rainbow = {
|
||||
enable = true,
|
||||
},
|
||||
})
|
||||
Loading…
Reference in a new issue