Skip to content

Commit

Permalink
make my own nvim lua setup
Browse files Browse the repository at this point in the history
  • Loading branch information
DivineGod committed Jan 24, 2023
1 parent d7cbb98 commit 98361f4
Show file tree
Hide file tree
Showing 16 changed files with 652 additions and 104 deletions.
16 changes: 16 additions & 0 deletions nvim/.config/nvim/after/plugin/colorscheme.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function color(colorscheme)
colorscheme = colorscheme or "everforest"

vim.o.background = "dark"
vim.g.everforest_background="soft"
vim.g.everforest_enable_italic=1


local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
if not status_ok then
return
end
end

color()

75 changes: 75 additions & 0 deletions nvim/.config/nvim/after/plugin/dap.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
local dap_status_ok, dap = pcall(require, "dap")
if not dap_status_ok then
return
end

local dap_ui_status_ok, dapui = pcall(require, "dapui")
if not dap_ui_status_ok then
return
end

local dap_install_status_ok, dap_install = pcall(require, "dap-install")
if not dap_install_status_ok then
return
end

dap_install.setup({})

dap_install.config("python", {})
-- add other configs here

dapui.setup({
expand_lines = true,
icons = { expanded = "", collapsed = "", circular = "" },
mappings = {
-- Use a table to apply multiple mappings
expand = { "<CR>", "<2-LeftMouse>" },
open = "o",
remove = "d",
edit = "e",
repl = "r",
toggle = "t",
},
layouts = {
{
elements = {
{ id = "scopes", size = 0.33 },
{ id = "breakpoints", size = 0.17 },
{ id = "stacks", size = 0.25 },
{ id = "watches", size = 0.25 },
},
size = 0.33,
position = "right",
},
{
elements = {
{ id = "repl", size = 0.45 },
{ id = "console", size = 0.55 },
},
size = 0.27,
position = "bottom",
},
},
floating = {
max_height = 0.9,
max_width = 0.5, -- Floats will be treated as percentage of your screen.
border = vim.g.border_chars, -- Border style. Can be 'single', 'double' or 'rounded'
mappings = {
close = { "q", "<Esc>" },
},
},
})

vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" })

dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
end

dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
end

dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
70 changes: 70 additions & 0 deletions nvim/.config/nvim/after/plugin/lsp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
local lsp = require("lsp-zero")

lsp.preset("recommended")

lsp.ensure_installed({
'tsserver',
'sumneko_lua',
'rust_analyzer',
})

-- Fix Undefined global 'vim'
lsp.configure('sumneko_lua', {
settings = {
Lua = {
diagnostics = {
globals = { 'vim' }
}
}
}
})


local cmp = require('cmp')
local cmp_select = {behavior = cmp.SelectBehavior.Select}
local cmp_mappings = lsp.defaults.cmp_mappings({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
})

-- disable completion with tab
-- this helps with copilot setup
cmp_mappings['<Tab>'] = nil
cmp_mappings['<S-Tab>'] = nil

lsp.setup_nvim_cmp({
mapping = cmp_mappings
})

lsp.set_preferences({
suggest_lsp_servers = false,
sign_icons = {
error = 'E',
warn = 'W',
hint = 'H',
info = 'I'
}
})

lsp.on_attach(function(client, bufnr)
local opts = {buffer = bufnr, remap = false}

vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
end)

lsp.setup()

vim.diagnostic.config({
virtual_text = true,
})
44 changes: 44 additions & 0 deletions nvim/.config/nvim/after/plugin/mason.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
local servers = {
}

local settings = {
ui = {
border = "none",
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
log_level = vim.log.levels.INFO,
max_concurrent_installers = 4,
}

require("mason").setup(settings)
require("mason-lspconfig").setup({
ensure_installed = servers,
automatic_installation = true,
})

local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
if not lspconfig_status_ok then
return
end

local opts = {}

for _, server in pairs(servers) do
opts = {
on_attach = require("user.lsp.handlers").on_attach,
capabilities = require("user.lsp.handlers").capabilities,
}

server = vim.split(server, "@")[1]

local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server)
if require_ok then
opts = vim.tbl_deep_extend("force", conf_opts, opts)
end

lspconfig[server].setup(opts)
end
24 changes: 24 additions & 0 deletions nvim/.config/nvim/after/plugin/null-ls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local null_ls_status_ok, null_ls = pcall(require, "null-ls")
if not null_ls_status_ok then
return
end

-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
local formatting = null_ls.builtins.formatting
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
local diagnostics = null_ls.builtins.diagnostics

-- https://github.com/prettier-solidity/prettier-plugin-solidity
null_ls.setup {
debug = false,
sources = {
formatting.prettier.with {
extra_filetypes = { "toml" },
extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" },
},
formatting.black.with { extra_args = { "--fast" } },
formatting.stylua,
formatting.google_java_format,
diagnostics.flake8,
},
}
22 changes: 22 additions & 0 deletions nvim/.config/nvim/after/plugin/project.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local status_ok, project = pcall(require, "project_nvim")
if not status_ok then
return
end
project.setup({

-- detection_methods = { "lsp", "pattern" }, -- NOTE: lsp detection will get annoying with multiple langs in one project
detection_methods = { "pattern" },

-- patterns used to detect root dir, when **"pattern"** is in detection_methods
patterns = { ".git" },

show_hidden = true
})

local tele_status_ok, telescope = pcall(require, "telescope")
if not tele_status_ok then
return
end

telescope.load_extension('projects')

46 changes: 46 additions & 0 deletions nvim/.config/nvim/after/plugin/telescope.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
local status_ok, telescope = pcall(require, "telescope")
if not status_ok then
return
end

local actions = require "telescope.actions"

local telescopeConfig = require("telescope.config")

-- Clone the default Telescope configuration
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }

-- I want to search in hidden/dot files.
table.insert(vimgrep_arguments, "--hidden")
-- I don't want to search in the `.git` directory.
table.insert(vimgrep_arguments, "--glob")
table.insert(vimgrep_arguments, "!**/.git/*")

telescope.setup {
defaults = {

prompt_prefix = "",
selection_caret = "",
-- path_display = { "smart" },
file_ignore_patterns = { ".git/", "node_modules" },

vimgrep_arguments = vimgrep_arguments,

pickers = {
find_files = {
-- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d.
find_command = { "fd", "--type", "f", "--strip-cwd-prefix", "--hidden", "--exclude", ".git"},
},
},

mappings = {
i = {
["<Down>"] = actions.cycle_history_next,
["<Up>"] = actions.cycle_history_prev,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
},
},
},
}

31 changes: 31 additions & 0 deletions nvim/.config/nvim/after/plugin/treesitter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
local status_ok, treesitter = pcall(require, "nvim-treesitter")
if not status_ok then
return
end

local status_ok, configs = pcall(require, "nvim-treesitter.configs")
if not status_ok then
return
end

configs.setup({
ensure_installed = { "lua", "markdown", "markdown_inline", "bash", "python", "rust", "vim" }, -- put the language you want in this array
-- ensure_installed = "all", -- one of "all" or a list of languages
ignore_install = { "" }, -- List of parsers to ignore installing
sync_install = false, -- install languages synchronously (only applied to `ensure_installed`)

highlight = {
enable = true, -- false will disable the whole extension
disable = { "" }, -- list of language that will be disabled
},
autopairs = {
enable = false,
},
indent = { enable = true, disable = { "python", "css" } },

context_commentstring = {
enable = true,
enable_autocmd = false,
},

})
23 changes: 1 addition & 22 deletions nvim/.config/nvim/init.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1 @@
require "user.impatient"
require "user.options"
require "user.keymaps"
require "user.plugins"
require "user.autocommands"
require "user.colorscheme"
require "user.cmp"
require "user.telescope"
require "user.gitsigns"
require "user.treesitter"
require "user.autopairs"
require "user.comment"
require "user.nvim-tree"
require "user.bufferline"
require "user.lualine"
require "user.toggleterm"
require "user.project"
require "user.illuminate"
require "user.indentline"
require "user.alpha"
require "user.lsp"
require "user.dap"
require "ando"
Loading

0 comments on commit 98361f4

Please sign in to comment.