Skip to content

Commit 0a0d3aa

Browse files
committed
Initial commit
0 parents  commit 0a0d3aa

File tree

9 files changed

+219
-0
lines changed

9 files changed

+219
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*_local.lua

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
My dotnvim
2+
==========
3+
4+
My configuration now that I moved to nvim completely

init.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
-- VSCode has a smaller configuration since it does all the file managing and lsp for you
2+
if vim.g.vscode then
3+
require("vscode_plugins")
4+
require("vscode") -- vscode only settings
5+
6+
-- vscode local settings
7+
if vim.api.nvim_get_runtime_file("lua/vscode_local.lua", false)[1] then
8+
require "vscode_local"
9+
end
10+
11+
-- exit early to prevent launching all the rest of the config that vscode don't care about
12+
do return end
13+
end
14+
15+
require("plugins")
16+
require("settings")
17+
18+
-- Load ginit.lua only for UI
19+
vim.api.nvim_create_autocmd("UIEnter", { once = true, callback = function() require "ginit" end })
20+
21+
-- Load UI local settings
22+
if vim.api.nvim_get_runtime_file("lua/ginit_local.lua", false)[1] then
23+
vim.api.nvim_create_autocmd("UIEnter", { once = true, callback = function() require "ginit_local" end })
24+
end
25+
26+
-- Load final overrites or local settings
27+
if vim.api.nvim_get_runtime_file("lua/init_local.lua", false)[1] then
28+
require "init_local"
29+
end

lua/ginit.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function set_font(name, size)
2+
if vim.fn.exists(":GuiFont") ~= 0
3+
then
4+
vim.api.nvim_command("GuiFont! " .. name .. ":h" .. size)
5+
end
6+
end
7+
8+
set_font("Iosevka", 16)

lua/global_settings.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
vim.api.nvim_set_var("mapleader", ",") -- map leader to ,
2+
3+
vim.api.nvim_create_user_command("W", "w", {}) -- make :W == :w
4+
5+
-- mappings
6+
vim.keymap.set("n", "<leader>3", ":noh<CR>") -- ,4 to clear search results
7+
vim.keymap.set("n", "<leader>l", ":set list!<CR>") -- ,l to show invisibles
8+
9+
-- movement without the extra ctrl+w
10+
vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', {})
11+
vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', {})
12+
vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', {})
13+
vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', {})
14+
15+
vim.api.nvim_set_keymap('n', ';', ':', {noremap = true}) -- ; to :
16+
17+
-- options
18+
vim.opt.startofline = false -- reopen on same line
19+
vim.opt.sm = true -- substitute with magic
20+
vim.opt.hlsearch = true -- search
21+
vim.opt.incsearch = true -- incremental
22+
vim.opt.ignorecase = true -- ignoring case
23+
vim.opt.smartcase = true -- with smartness
24+
vim.opt.wildignorecase = true -- and with wildcard ignore case

lua/plugins.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
return require("packer").startup(function()
2+
use "igorgue/danger" -- danger colorscheme
3+
use "tpope/vim-sensible" -- sensible default vim settings by tpope
4+
use "wbthomason/packer.nvim" -- packer update itself
5+
use { -- nice interface for LSP functions (among other things)
6+
"nvim-telescope/telescope.nvim",
7+
requires = { {"nvim-lua/plenary.nvim"} }
8+
}
9+
use "neovim/nvim-lspconfig" -- native LSP support
10+
use "L3MON4D3/LuaSnip" -- Lua based snippets
11+
12+
-- hrsh7th's nvim lsp plugins
13+
use "hrsh7th/cmp-nvim-lsp"
14+
use "hrsh7th/cmp-buffer"
15+
use "hrsh7th/cmp-path"
16+
use "hrsh7th/cmp-cmdline"
17+
use "hrsh7th/nvim-cmp"
18+
use "hrsh7th/cmp-nvim-lsp-signature-help"
19+
use "saadparwaiz1/cmp_luasnip" -- snippets required for hrsh7th's plugins
20+
use "hrsh7th/cmp-nvim-lua" -- lua support
21+
use "hrsh7th/cmp-nvim-lsp-document-symbol"
22+
use "ray-x/cmp-treesitter"
23+
end)

lua/settings.lua

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
require("global_settings")
2+
3+
-- my theme: danger
4+
vim.opt.background = "dark"
5+
vim.cmd("colorscheme danger")
6+
7+
vim.opt.encoding = "utf-8"
8+
9+
-- tab settings
10+
vim.opt.tabstop = 4
11+
vim.opt.shiftwidth = 4
12+
vim.opt.softtabstop = 4
13+
vim.opt.expandtab = true
14+
15+
-- completion menu
16+
vim.opt.wildmenu = true
17+
vim.opt.wildmode = "list:longest,list:full"
18+
vim.opt.wildignore:append("*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/*,*.bak,*.exe,*.pyc,*.dll,*.pdb,*.DS_Store,*.db,env,*/debug/*,*/Debug/*,*/publish/*")
19+
20+
vim.opt.undofile = true
21+
22+
vim.opt.tags = "tags;$HOME/.config/nvim/tags/;$HOME/tmp/tags/" -- find ctags
23+
vim.opt.listchars = [[tab:▸\ ,eol:¬]] -- listchars for invisibles
24+
vim.opt.mouse = "a" -- fix mouse
25+
vim.opt.ls = 2 -- status line always show
26+
vim.opt.scrolloff = 5 -- show 5 lines before cursor always
27+
vim.opt.showcmd = true -- display incomplete commands
28+
vim.opt.showmode = true -- display current mode
29+
vim.opt.linebreak = true -- show line breaks
30+
vim.opt.wrap = true -- wrap lines
31+
vim.opt.title = true -- title in the console
32+
vim.opt.sm = true -- show matching braces
33+
vim.opt.ttyfast = true -- smoother changes
34+
vim.opt.shortmess = "atI" -- abbreviate messages
35+
vim.opt.backupdir = "/tmp" -- backup directory
36+
vim.opt.showtabline = 1 -- always show the tab line
37+
vim.opt.hidden = true -- has to do with undo in buffer I think...
38+
vim.opt.cursorline = true -- show cursor where my cursor is...
39+
vim.opt.lazyredraw = true -- better redrawing of text
40+
vim.opt.termguicolors = true -- 24 bit term gui colors
41+
42+
vim.keymap.set("n", "<leader>1", ":NerdTreeToggle<CR>")
43+
vim.keymap.set("n", "<leader>2", ":NerdTreeToggle<CR>")
44+
45+
-- autocomplete options
46+
vim.opt.completeopt=menu,menuone,noselect
47+
48+
-- setup nvim-cmp.
49+
local cmp = require"cmp"
50+
51+
cmp.setup({
52+
snippet = {
53+
-- REQUIRED - you must specify a snippet engine
54+
expand = function(args)
55+
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
56+
require("luasnip").lsp_expand(args.body) -- For `luasnip` users.
57+
-- require("snippy").expand_snippet(args.body) -- For `snippy` users.
58+
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
59+
end,
60+
},
61+
window = {
62+
-- completion = cmp.config.window.bordered(),
63+
-- documentation = cmp.config.window.bordered(),
64+
},
65+
mapping = cmp.mapping.preset.insert({
66+
["<C-b>"] = cmp.mapping.scroll_docs(-4),
67+
["<C-f>"] = cmp.mapping.scroll_docs(4),
68+
["<C-Space>"] = cmp.mapping.complete(),
69+
["<C-e>"] = cmp.mapping.abort(),
70+
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
71+
["<Tab>"] = cmp.mapping.confirm({ select = true }),
72+
}),
73+
sources = cmp.config.sources({
74+
{ name = "nvim_lsp" },
75+
-- { name = "vsnip" }, -- For vsnip users.
76+
{ name = "luasnip" }, -- For luasnip users.
77+
-- { name = "ultisnips" }, -- For ultisnips users.
78+
-- { name = "snippy" }, -- For snippy users.
79+
{ name = "nvim_lua" },
80+
{ name = "nvim_lsp_signature_help" },
81+
{ name = "treesitter" },
82+
{ name = "path" },
83+
}, {
84+
{ name = "buffer" },
85+
})
86+
})
87+
88+
-- Set configuration for specific filetype.
89+
cmp.setup.filetype("gitcommit", {
90+
sources = cmp.config.sources({
91+
{ name = "cmp_git" }, -- You can specify the `cmp_git` source if you were installed it.
92+
}, {
93+
{ name = "buffer" },
94+
})
95+
})
96+
97+
-- Use buffer source for `/` (if you enabled `native_menu`, this won"t work anymore).
98+
cmp.setup.cmdline("/", {
99+
mapping = cmp.mapping.preset.cmdline(),
100+
sources = {
101+
{ name = "nvim_lsp_document_symbol" }
102+
}, {
103+
{ name = "buffer" }
104+
}
105+
})
106+
107+
-- Use cmdline & path source for ":" (if you enabled `native_menu`, this won"t work anymore).
108+
cmp.setup.cmdline(":", {
109+
mapping = cmp.mapping.preset.cmdline(),
110+
sources = cmp.config.sources({
111+
{ name = "path" }
112+
}, {
113+
{ name = "cmdline" }
114+
})
115+
})
116+
117+
-- Setup lspconfig.
118+
local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
119+
120+
-- Replace <YOUR_LSP_SERVER> with each lsp server you"ve enabled.
121+
require("lspconfig")["pyright"].setup {
122+
capabilities = capabilities
123+
}

lua/vscode.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require("global_settings")

lua/vscode_plugins.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
return require("packer").startup(function()
2+
use "michaeljsmith/vim-indent-object" -- selection of indentation blocks
3+
use "preservim/nerdcommenter" -- comment and uncomment
4+
use "tpope/vim-sensible" -- sensible default vim settings
5+
use "tpope/vim-surround" -- wrap objects with text
6+
end)

0 commit comments

Comments
 (0)