Skip to content

Merge Latest #1566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .stylua.toml

This file was deleted.

195 changes: 144 additions & 51 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ I hope you enjoy your Neovim journey,

P.S. You can delete this when you're done too. It's your config now :)
--]]

-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

vim.o.termguicolors = true

-- Install package manager
-- https://github.com/folke/lazy.nvim
-- `:help lazy.nvim.txt` for more info
Expand Down Expand Up @@ -75,7 +76,8 @@ require('lazy').setup({

-- NOTE: This is where your plugins related to LSP can be installed.
-- The configuration is done below. Search for lspconfig to find it below.
{ -- LSP Configuration & Plugins
{
-- LSP Configuration & Plugins
'neovim/nvim-lspconfig',
dependencies = {
-- Automatically install LSPs to stdpath for neovim
Expand All @@ -91,14 +93,16 @@ require('lazy').setup({
},
},

{ -- Autocompletion
{
-- Autocompletion
'hrsh7th/nvim-cmp',
dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' },
},

-- Useful plugin to show you pending keybinds.
{ 'folke/which-key.nvim', opts = {} },
{ -- Adds git releated signs to the gutter, as well as utilities for managing changes
{ 'folke/which-key.nvim', opts = {} },
{
-- Adds git releated signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
opts = {
-- See `:help gitsigns.txt`
Expand All @@ -112,39 +116,63 @@ require('lazy').setup({
},
},

{ -- Theme inspired by Atom
{
-- Theme inspired by Atom
'navarasu/onedark.nvim',
priority = 1000,
config = function()
require('onedark').setup {
style = 'warmer',
transparent = true,
-- code_style = {
-- comments = 'none',
-- },
}
require('onedark').load()
vim.cmd.colorscheme 'onedark'
end,
},
-- {
-- 'morhetz/gruvbox',
-- config = function()
-- vim.cmd.colorscheme 'gruvbox'
-- vim.o.background = 'dark'
-- vim.o.termguicolors = true
-- end
-- },

{ -- Set lualine as statusline
{
-- Set lualine as statusline
'nvim-lualine/lualine.nvim',
-- See `:help lualine.txt`
opts = {
options = {
icons_enabled = false,
theme = 'onedark',
theme = 'gruvbox',
component_separators = '|',
section_separators = '',
},
},
},

{ -- Add indentation guides even on blank lines
{
-- Add indentation guides even on blank lines
'lukas-reineke/indent-blankline.nvim',
-- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help indent_blankline.txt`
opts = {
char = '┊',
show_trailing_blankline_indent = false,
},
main = 'ibl',
config = function()
require('ibl').setup {
indent = { char = "┊" },
whitespace = {
remove_blankline_trail = true,
},
}
end,
},

-- "gc" to comment visual regions/lines
{ 'numToStr/Comment.nvim', opts = {} },
{ 'numToStr/Comment.nvim', opts = {} },

-- Fuzzy Finder (files, lsp, etc)
{ 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } },
Expand All @@ -162,7 +190,8 @@ require('lazy').setup({
end,
},

{ -- Highlight, edit, and navigate code
{
-- Highlight, edit, and navigate code
'nvim-treesitter/nvim-treesitter',
dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects',
Expand All @@ -175,8 +204,8 @@ require('lazy').setup({
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
-- These are some example plugins that I've included in the kickstart repository.
-- Uncomment any of the lines below to enable them.
-- require 'kickstart.plugins.autoformat',
-- require 'kickstart.plugins.debug',
require 'kickstart.plugins.autoformat',
require 'kickstart.plugins.debug',

-- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping
Expand Down Expand Up @@ -204,7 +233,7 @@ vim.o.mouse = 'a'
-- Sync clipboard between OS and Neovim.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
vim.o.clipboard = 'unnamedplus'
-- vim.o.clipboard = 'unnamedplus'

-- Enable break indent
vim.o.breakindent = true
Expand All @@ -230,6 +259,18 @@ vim.o.completeopt = 'menuone,noselect'
-- NOTE: You should make sure your terminal supports this
vim.o.termguicolors = true

-- Set relative and absolute line numbers
vim.o.relativenumber = true
vim.o.number = true

-- Set scroll offsets to have additional space when scrolling
vim.o.scrolloff = 5
vim.o.sidescrolloff = 10

-- Set tabs to 2 spaces
vim.o.tabstop = 2
vim.o.softtabstop = 2

-- [[ Basic Keymaps ]]

-- Keymaps for better default experience
Expand All @@ -240,6 +281,15 @@ vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })

-- Map window slection
vim.keymap.set('n', '<M-h>', "<C-w>h", { silent = true })
vim.keymap.set('n', '<M-j>', "<C-w>j", { silent = true })
vim.keymap.set('n', '<M-k>', "<C-w>k", { silent = true })
vim.keymap.set('n', '<M-l>', "<C-w>l", { silent = true })

-- Map copy to clipboard
vim.keymap.set('v', '<leader>y', "\"+y", { silent = true })

-- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()`
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
Expand Down Expand Up @@ -269,7 +319,7 @@ pcall(require('telescope').load_extension, 'fzf')

-- See `:help telescope.builtin`
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>b', require('telescope.builtin').buffers, { desc = 'Find existing [b]uffers' })
vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to telescope to change theme, layout, etc.
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
Expand All @@ -288,10 +338,11 @@ vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { de
-- See `:help nvim-treesitter`
require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'help', 'vim' },
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vim', 'ruby', 'http',
'css' },

-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = false,
auto_install = true,

highlight = { enable = true },
indent = { enable = true, disable = { 'python' } },
Expand Down Expand Up @@ -374,7 +425,7 @@ local on_attach = function(_, bufnr)
end

nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
nmap('<c-a>', vim.lsp.buf.code_action, '[C]ode [A]ction')

nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
Expand All @@ -384,8 +435,8 @@ local on_attach = function(_, bufnr)
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')

-- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
nmap('<c-i>', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<c-p>', vim.lsp.buf.signature_help, 'Signature Documentation')

-- Lesser used LSP functionality
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
Expand All @@ -399,6 +450,11 @@ local on_attach = function(_, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })

nmap('<leader><C-f>', function() vim.lsp.buf.format { async = true } end, 'Auto [F]ormat')

nmap('[e', vim.diagnostic.goto_next, 'Next [e]rror')
nmap(']e', vim.diagnostic.goto_prev, 'Prev [e]rror')
end

-- Enable the following language servers
Expand All @@ -407,18 +463,53 @@ end
-- Add any additional override configuration in the following tables. They will be passed to
-- the `settings` field of the server config. You must look up that documentation yourself.
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
-- tsserver = {},

clangd = {
cmd = {
"~/.local/share/nvim/mason/bin/clangd",
"--all-scopes-completion",
"--background-index",
"--clang-tidy",
"--completion-parse=always",
"--completion-style=bundled",
"--cross-file-rename",
"--debug-origin",
"--enable-config", -- clangd 11+ supports reading from .clangd configuration file
"--fallback-style=Qt",
"--folding-ranges",
"--function-arg-placeholders",
"--header-insertion=iwyu",
"--pch-storage=memory", -- could also be disk
"--suggest-missing-includes",
"-j=20", -- number of workers
-- "--resource-dir="
"--log=error",
},
},
gopls = {},
-- solargraph = {},
ruby_lsp = {},
sqlls = {},
angularls = {},
bashls = {},
cssls = {},
dockerls = {},
-- gradle_ls = {},
pyright = {},
ts_ls = {},
html = {},
jsonls = {},
-- jdtls = {},
rust_analyzer = {},
-- marksman = {},
volar = {},
yamlls = {},
lua_ls = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
},
tailwindcss = {},
}

-- Setup neovim lua configuration
Expand Down Expand Up @@ -461,37 +552,39 @@ cmp.setup {
end,
},
mapping = cmp.mapping.preset.insert {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {},
['<M-d>'] = cmp.mapping.scroll_docs(-4),
['<M-f>'] = cmp.mapping.scroll_docs(4),
['<M-Space>'] = cmp.mapping.complete {},
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
-- ['<Tab>'] = cmp.mapping(function(fallback)
-- if cmp.visible() then
-- cmp.select_next_item()
-- elseif luasnip.expand_or_jumpable() then
-- luasnip.expand_or_jump()
-- else
-- fallback()
-- end
-- end, { 'i', 's' }),
-- ['<S-Tab>'] = cmp.mapping(function(fallback)
-- if cmp.visible() then
-- cmp.select_prev_item()
-- elseif luasnip.jumpable(-1) then
-- luasnip.jump(-1)
-- else
-- fallback()
-- end
-- end, { 'i', 's' }),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
}

-- vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]]

-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
4 changes: 4 additions & 0 deletions lua/custom/plugins/abolish.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- User :%S to replace words with smart case
return {
'tpope/vim-abolish',
}
25 changes: 25 additions & 0 deletions lua/custom/plugins/autosession.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
return {
'rmagatti/auto-session',
config = function()
require("auto-session").setup {
suppressed_dirs = { "~/", "~/Downloads", "/" },
use_git_branch = true,
auto_restore_enabled = true,
pre_cwd_changed_cmds = {
"Neotree close"
},
-- pre_save_cmds = {
-- "tabdo Neotree close"
-- },
-- post_save_cmds = {
-- "tabdo Neotree"
-- },
-- pre_restore_cmds = {
-- "tabdo Neotree close"
-- },
-- post_restore_cmds = {
-- "tabdo Neotree"
-- },
}
end
}
Loading
Loading