Skip to content

Commit c664177

Browse files
committed
add neovim config
turn out dot-config -> .config not actually working gh issues has been open for a while aspiers/stow#33
1 parent 516c2fa commit c664177

19 files changed

+571
-2
lines changed

.config/nvim/after/plugin/cmp.lua

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
local cmp = require('cmp')
2+
3+
cmp.setup({
4+
sources = {
5+
{
6+
name = "nvim_lsp",
7+
priority = 1000
8+
},
9+
{
10+
name = "luasnip",
11+
priority = 750
12+
},
13+
{
14+
name = "buffer",
15+
priority = 500
16+
},
17+
{
18+
name = "path",
19+
priority = 250
20+
}
21+
},
22+
mapping = cmp.mapping.preset.insert({
23+
-- Enter key confirms completion item
24+
['<CR>'] = cmp.mapping.confirm({
25+
select = false
26+
}),
27+
28+
-- Ctrl + space triggers completion menu
29+
['<C-Space>'] = cmp.mapping.complete()
30+
}),
31+
snippet = {
32+
expand = function(args) require('luasnip').lsp_expand(args.body) end
33+
}
34+
})
35+

.config/nvim/after/plugin/conf.lua

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require("neoconf").setup();
2+
require("neodev").setup();
3+
require('nvim-ts-autotag').setup()
4+
require('Comment').setup({
5+
pre_hook = require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook()
6+
})
7+
require('ts_context_commentstring').setup({})
8+
require("bufferline").setup {}
9+
require("transparent").setup()

.config/nvim/after/plugin/lsp.lua

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
require("luasnip.loaders.from_vscode").lazy_load()
2+
3+
vim.keymap.set('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
4+
vim.keymap.set('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
5+
vim.keymap.set('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
6+
7+
vim.api.nvim_create_autocmd('LspAttach', {
8+
desc = 'LSP actions',
9+
callback = function(args)
10+
local bufnr = args.buf
11+
local client = vim.lsp.get_client_by_id(args.data.client_id)
12+
13+
local opts = {
14+
buffer = bufnr
15+
}
16+
17+
require("which-key").register({
18+
['K'] = {
19+
function() vim.lsp.buf.hover() end,
20+
'Hover Diagnostic'
21+
},
22+
["g"] = {
23+
d = {
24+
function() vim.lsp.buf.definition() end,
25+
'Jump Definition'
26+
},
27+
D = {
28+
function() vim.lsp.buf.declaration() end,
29+
'Jump Declaration'
30+
},
31+
i = {
32+
function() vim.lsp.buf.implementation() end,
33+
'View Implementation'
34+
},
35+
o = {
36+
function() vim.lsp.buf.type_definition() end,
37+
'Jump Type Definition'
38+
},
39+
r = {
40+
function() vim.lsp.buf.references() end,
41+
'View References'
42+
},
43+
s = {
44+
function() vim.lsp.buf.signature_help() end,
45+
'Signature Help'
46+
}
47+
},
48+
["<leader>l"] = {
49+
r = {
50+
function() vim.lsp.buf.rename() end,
51+
'Rename'
52+
},
53+
a = {
54+
function() vim.lsp.buf.code_action() end,
55+
'Code Action'
56+
}
57+
}
58+
59+
}, opts)
60+
61+
end
62+
})

.config/nvim/after/plugin/mason.lua

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities()
2+
3+
local default_setup = function(server)
4+
require('lspconfig')[server].setup({
5+
capabilities = lsp_capabilities
6+
})
7+
8+
end
9+
10+
require('mason').setup({})
11+
require('mason-lspconfig').setup({
12+
ensure_installed = {
13+
"clangd",
14+
"eslint",
15+
"html",
16+
"lua_ls",
17+
"rust_analyzer",
18+
"tailwindcss",
19+
"tsserver",
20+
"typos_lsp"
21+
22+
},
23+
handlers = {
24+
default_setup
25+
}
26+
})
27+
28+
local required_formatters = {
29+
"black",
30+
"clang-format",
31+
"luaformatter",
32+
"prettier"
33+
}
34+
35+
for _, value in pairs(required_formatters) do
36+
if not require("mason-registry").is_installed(value) then
37+
vim.cmd("MasonInstall " .. value)
38+
end
39+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
local formatters = require("formatter.defaults");
2+
local util = require "formatter.util"
3+
4+
local lua_format = function()
5+
return {
6+
exe = "lua-format",
7+
stdin = true,
8+
args = {
9+
"--column-table-limit=1"
10+
}
11+
}
12+
end
13+
14+
require("formatter").setup {
15+
logging = true,
16+
log_level = vim.log.levels.WARN,
17+
filetype = {
18+
lua = lua_format,
19+
rust = require("formatter.filetypes.rust").rustfmt,
20+
cpp = require("formatter.filetypes.cpp").clangformat,
21+
python = require("formatter.filetypes.python").black,
22+
23+
-- JS Land
24+
javascript = formatters.prettier,
25+
javascriptreact = formatters.prettier,
26+
typescript = formatters.prettier,
27+
typescriptreact = formatters.prettier,
28+
css = formatters.prettier,
29+
scss = formatters.prettier,
30+
less = formatters.prettier,
31+
html = formatters.prettier,
32+
json = formatters.prettier,
33+
yaml = formatters.prettier,
34+
markdown = formatters.prettier,
35+
graphql = formatters.prettier,
36+
vue = formatters.prettier,
37+
svelte = formatters.prettier
38+
39+
}
40+
}
41+
42+
local augroup = vim.api.nvim_create_augroup
43+
local autocmd = vim.api.nvim_create_autocmd
44+
augroup("__formatter__", {
45+
clear = true
46+
})
47+
autocmd("BufWritePost", {
48+
group = "__formatter__",
49+
command = ":FormatWriteLock"
50+
})
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require("lint").linters_by_ft = {}
2+
3+
vim.api.nvim_create_autocmd({
4+
"BufWritePost"
5+
}, {
6+
callback = function()
7+
require("lint").try_lint()
8+
end
9+
})

.config/nvim/after/plugin/rich.lua

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require("presence").setup({
2+
main_image = "file"
3+
})
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require'nvim-treesitter.configs'.setup {
2+
ensure_installed = {},
3+
modules = {},
4+
ignore_install = {},
5+
6+
sync_install = false,
7+
8+
auto_install = true,
9+
10+
highlight = {
11+
enable = true,
12+
additional_vim_regex_highlighting = false
13+
},
14+
15+
autotag = {
16+
enable = true
17+
}
18+
}

.config/nvim/init.lua

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
vim.g.loaded_netrwPlugin = 1
2+
vim.g.loaded_netrw = 1
3+
4+
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
5+
if not vim.loop.fs_stat(lazypath) then
6+
vim.fn.system({
7+
"git",
8+
"clone",
9+
"--filter=blob:none",
10+
"https://github.com/folke/lazy.nvim.git",
11+
"--branch=stable", -- latest stable release
12+
lazypath
13+
})
14+
end
15+
vim.opt.rtp:prepend(lazypath)
16+
vim.loader.enable()
17+
vim.g.mapleader = " "
18+
19+
require("lazy").setup("plugins") -- Load Plugins
20+
require("config.keybinds") -- Load keybinds
21+
require("config.default_settings"); -- Load Settings
22+
require("config.autocmd");
23+
24+
vim.cmd.colorscheme "catppuccin"

.config/nvim/lazy-lock.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
3+
"LuaSnip": { "branch": "master", "commit": "f3b3d3446bcbfa62d638b1903ff00a78b2b730a1" },
4+
"bufferline.nvim": { "branch": "main", "commit": "d6cb9b7cac52887bcac65f8698e67479553c0748" },
5+
"catppuccin": { "branch": "main", "commit": "9703f227bfab20d04bcee62d2f08f1795723b4ae" },
6+
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
7+
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
8+
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
9+
"dashboard-nvim": { "branch": "master", "commit": "413442b12d85315fc626c44a0ce4929b213ef604" },
10+
"formatter.nvim": { "branch": "master", "commit": "cb4778b8432f1ae86dae4634c0b611cb269a4c2f" },
11+
"friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" },
12+
"lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" },
13+
"lsp-zero.nvim": { "branch": "v3.x", "commit": "abac76482ec3012a2b359ba956a74e2ffd33d46f" },
14+
"mason-lspconfig.nvim": { "branch": "main", "commit": "60f6805b12a12e8a912aeb2f975dec1794a8994e" },
15+
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
16+
"neo-tree.nvim": { "branch": "main", "commit": "7d3b02073e59ed9ef271795787de76d0de8f5294" },
17+
"neoconf.nvim": { "branch": "main", "commit": "4ef6c6c5882e7e16209173fb8c47414202843384" },
18+
"neodev.nvim": { "branch": "main", "commit": "fdf6b3c58caf3ed1bfe40822d5dac340fc18c33b" },
19+
"nui.nvim": { "branch": "main", "commit": "c3c7fd618dcb5a89e443a2e1033e7d11fdb0596b" },
20+
"nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" },
21+
"nvim-lint": { "branch": "master", "commit": "99f93757276ea55c35bbe74ad2a3d25fc504643b" },
22+
"nvim-lspconfig": { "branch": "master", "commit": "aa199c5bbdbb7fd28b56212a89206f13db02799e" },
23+
"nvim-treesitter": { "branch": "master", "commit": "ca46eb3ac96cd96e963895004589f0c9b2a44491" },
24+
"nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" },
25+
"nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" },
26+
"nvim-web-devicons": { "branch": "master", "commit": "14ac5887110b06b89a96881d534230dac3ed134d" },
27+
"plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" },
28+
"presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" },
29+
"telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
30+
"transparent.nvim": { "branch": "main", "commit": "fd35a46f4b7c1b244249266bdcb2da3814f01724" },
31+
"ultimate-autopair.nvim": { "branch": "v0.6", "commit": "f4125108b58f2a3a5bb30bcee91927ea88cdfa34" },
32+
"undotree": { "branch": "master", "commit": "9dbbf3b7d19dda0d22ceca461818e4739ad8154d" },
33+
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
34+
}

.config/nvim/lua/config/autocmd.lua

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
vim.api.nvim_create_augroup("dashboard_open", {
2+
clear = true
3+
});
4+
5+
vim.api.nvim_create_autocmd("VimEnter", {
6+
desc = "Open Dashboard",
7+
group = "dashboard_open",
8+
once = true,
9+
callback = function()
10+
if not vim.g.dashboard_opened then
11+
-- vim.cmd "Dashboard"
12+
if vim.fn.argc() > 0 then vim.cmd "Neotree show" end
13+
vim.g.dashboard_opened = true
14+
end
15+
end
16+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
vim.wo.nu = true;
2+
vim.wo.relativenumber = true;
3+
4+
-- Use system clipboard
5+
vim.opt.clipboard = 'unnamedplus'
6+
7+
-- persistent undo
8+
vim.opt.undodir = "/tmp/nvim_undo"
9+
vim.opt.undofile = true
10+
11+
vim.opt.smartindent = true;
12+
13+
vim.opt.hlsearch = false;
14+
vim.opt.incsearch = true;
15+
16+
vim.opt.termguicolors = true;
17+
18+
vim.opt.scrolloff = 8;
19+
20+
vim.opt.updatetime = 50;
21+
22+
vim.opt.colorcolumn = "80";
23+
vim.opt.wrap = false;
24+
25+
vim.opt.tabstop = 4;
26+
vim.opt.shiftwidth = 4;
27+
vim.opt.expandtab = true;

0 commit comments

Comments
 (0)