1
0
Fork 0

fix spaces

As it turns out, you not confused with tabs and spaces settings.
And in some editors it's has some stange, kinda weird optins e.g
"shiftwidth", "tabstop", and "expandtab" (inserting spaces).

Kinda weird and I don't understand why?
This commit is contained in:
CRy386i 2024-11-30 00:32:37 +02:00
parent fd509a515b
commit 83d0eff656
3 changed files with 242 additions and 240 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.json

View file

@ -5,20 +5,21 @@ local g = vim.g
-- Set the numbers of whitespace characters when shifting with "<" or ">". -- Set the numbers of whitespace characters when shifting with "<" or ">".
-- In fact, in spite of expandtab, the terminal still displays whitespace charaters, -- In fact, in spite of expandtab, the terminal still displays whitespace charaters,
-- so let's set the number of whitespace characters for ones press of these buttons. -- so let's set the number of whitespace characters for ones press of these buttons.
opt.shiftwidth = 2 opt.shiftwidth = 4
-- one tab == two whitespace characters in new line. -- one tab == two whitespace characters in new line.
-- Pressing <CR> will insert tabs. Tabs are drawn as whitespace. -- Pressing <CR> will insert tabs. Tabs are drawn as whitespace.
-- that's why we have to set that each tab on a new line is two whitespace. -- that's why we have to set that each tab on a new line is two whitespace.
opt.tabstop = 2 opt.tabstop = 4
-- Adjust new line to the previous indentation -- Adjust new line to the previous indentation.
opt.smartindent = true opt.smartindent = true
opt.expandtab = false -- On pressing tab, insert 4 spaces.
opt.expandtab = true
opt.smarttab = true opt.smarttab = true
opt.scrolloff = 8 opt.scrolloff = 8
-- Show unprintable -- Show unprintable.
opt.list = true opt.list = true
opt.listchars = {tab = '', eol = '¬', trail = '·'} opt.listchars = {tab = '', eol = '¬', trail = '·'}

View file

@ -13,252 +13,252 @@ vim.opt.rtp:prepend(lazypath)
-- Install plugins using lazy -- Install plugins using lazy
require('lazy').setup({ require('lazy').setup({
{ 'tpope/vim-commentary', }, { 'tpope/vim-commentary', },
{ 'tpope/vim-fugitive', }, { 'tpope/vim-fugitive', },
{ 'sheerun/vim-polyglot', { 'sheerun/vim-polyglot',
init = function() init = function()
-- vim-polyglot confusingly registers *.comp both for perl and for glsl -- vim-polyglot confusingly registers *.comp both for perl and for glsl
vim.api.nvim_set_var('polyglot_disabled', {'perl'}) vim.api.nvim_set_var('polyglot_disabled', {'perl'})
end, end,
}, },
{ {
'morhetz/gruvbox', 'morhetz/gruvbox',
lazy = false, lazy = false,
priority = 1000, priority = 1000,
config = function() config = function()
vim.opt.background = 'dark' vim.opt.background = 'dark'
vim.g.gruvbox_italic = 1 vim.g.gruvbox_italic = 1
vim.cmd([[colorscheme gruvbox]]) vim.cmd([[colorscheme gruvbox]])
end, end,
}, },
{ {
"folke/tokyonight.nvim", "folke/tokyonight.nvim",
lazy = true, lazy = true,
-- config = function() -- config = function()
-- -- load the colorscheme here -- -- load the colorscheme here
-- vim.cmd([[colorscheme tokyonight]]) -- vim.cmd([[colorscheme tokyonight]])
-- end, -- end,
}, },
{ 'nvim-telescope/telescope-fzf-native.nvim', { 'nvim-telescope/telescope-fzf-native.nvim',
build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build'
}, },
{ {
'nvim-telescope/telescope.nvim', tag = '0.1.6', 'nvim-telescope/telescope.nvim', tag = '0.1.6',
dependencies = { 'nvim-lua/plenary.nvim' }, dependencies = { 'nvim-lua/plenary.nvim' },
config = function() config = function()
local telescope = require('telescope') local telescope = require('telescope')
telescope.setup{ telescope.setup{
-- defaults = { -- defaults = {
-- } -- }
extensions = { extensions = {
fzf = { fzf = {
fuzzy = true, -- false will only do exact matching fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case" case_mode = "smart_case", -- or "ignore_case" or "respect_case"
-- the default case_mode is "smart_case" -- the default case_mode is "smart_case"
} }
} }
} }
--telescope.load_extension('fzy') --telescope.load_extension('fzy')
telescope.load_extension('fzf') telescope.load_extension('fzf')
local builtin = require('telescope.builtin') local builtin = require('telescope.builtin')
vim.keymap.set('n', '<C-p>', builtin.find_files, {}) vim.keymap.set('n', '<C-p>', builtin.find_files, {})
vim.keymap.set('n', '<leader>ft', builtin.treesitter, {}) vim.keymap.set('n', '<leader>ft', builtin.treesitter, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {}) vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {}) vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {}) vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
end end
}, },
{ "nvim-treesitter/nvim-treesitter", { "nvim-treesitter/nvim-treesitter",
build = ":TSUpdate", build = ":TSUpdate",
config = function() config = function()
require("nvim-treesitter.configs").setup { require("nvim-treesitter.configs").setup {
ensure_installed = { "c", "cpp", "pascal", "lua", "glsl", "yaml" }, ensure_installed = { "c", "cpp", "pascal", "lua", "glsl", "yaml" },
highlight = { enable = true, } highlight = { enable = true, }
} }
end end
}, },
{ {
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
config = function() config = function()
-- Setup language servers. -- Setup language servers.
local lspconfig = require('lspconfig') local lspconfig = require('lspconfig')
lspconfig.clangd.setup {} --lspconfig.clangd.setup {}
lspconfig.neocmake.setup {} --lspconfig.neocmake.setup {}
-- Global mappings. -- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions -- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float) vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next) vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist) vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
-- Use LspAttach autocommand to only map the following keys -- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer -- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}), group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev) callback = function(ev)
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
-- Buffer local mappings. -- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf } local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts) vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts) vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts) vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<space>wl', function() vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts) end, opts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts) vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts) vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts) vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', '<space>f', function() vim.keymap.set('n', '<space>f', function()
vim.lsp.buf.format { async = true } vim.lsp.buf.format { async = true }
end, opts) end, opts)
end, end,
}) })
end end
}, },
{ {
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
dependencies = { dependencies = {
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer', 'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path', 'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-vsnip', 'hrsh7th/cmp-vsnip',
'hrsh7th/vim-vsnip', 'hrsh7th/vim-vsnip',
'hrsh7th/cmp-nvim-lsp-signature-help', 'hrsh7th/cmp-nvim-lsp-signature-help',
}, },
config = function() config = function()
local cmp = require'cmp' local cmp = require'cmp'
cmp.setup({ cmp.setup({
snippet = { snippet = {
-- REQUIRED - you must specify a snippet engine -- REQUIRED - you must specify a snippet engine
expand = function(args) expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
-- require('snippy').expand_snippet(args.body) -- For `snippy` users. -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
end, end,
}, },
window = { window = {
-- completion = cmp.config.window.bordered(), -- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(), -- documentation = cmp.config.window.bordered(),
}, },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4), ['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(), ['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(), ['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lsp' }, { name = 'nvim_lsp' },
{ name = 'vsnip' }, -- For vsnip users. { name = 'vsnip' }, -- For vsnip users.
-- { name = 'luasnip' }, -- For luasnip users. -- { name = 'luasnip' }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users. -- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users. -- { name = 'snippy' }, -- For snippy users.
}, { }, {
{ name = 'buffer' }, { name = 'buffer' },
{ name = 'nvim_lsp_signature_help' }, { name = 'nvim_lsp_signature_help' },
}) })
}) })
-- Set configuration for specific filetype. -- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', { cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
}, { }, {
{ name = 'buffer' }, { name = 'buffer' },
}) })
}) })
cmp.setup.filetype('cmake', { cmp.setup.filetype('cmake', {
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'cmake', "CMakeLists.txt" }, { name = 'cmake', "CMakeLists.txt" },
}, { }, {
{ name = 'buffer' }, { name = 'buffer' },
}) })
}) })
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, { cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
sources = { sources = {
{ name = 'buffer' } { name = 'buffer' }
} }
}) })
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', { cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(), mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'path' } { name = 'path' }
}, { }, {
{ name = 'cmdline' } { name = 'cmdline' }
}) })
}) })
-- Set up lspconfig. -- Set up lspconfig.
local capabilities = require('cmp_nvim_lsp').default_capabilities() local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- TODO Replace <YOUR_LSP_SERVER> with each lsp server you've enabled. -- TODO Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
require('lspconfig')['clangd'].setup { --[[require('lspconfig')['clangd'].setup {
capabilities = capabilities capabilities = capabilities
} }--]]
end, end,
}, },
{ {
'stevearc/aerial.nvim', 'stevearc/aerial.nvim',
dependencies = { 'neovim/nvim-lspconfig', }, dependencies = { 'neovim/nvim-lspconfig', },
config = function() config = function()
require('aerial').setup({ require('aerial').setup({
-- optionally use on_attach to set keymaps when aerial has attached to a buffer -- optionally use on_attach to set keymaps when aerial has attached to a buffer
on_attach = function(bufnr) on_attach = function(bufnr)
-- Jump forwards/backwards with '{' and '}' -- Jump forwards/backwards with '{' and '}'
vim.keymap.set('n', '{', '<cmd>AerialPrev<CR>', {buffer = bufnr}) vim.keymap.set('n', '{', '<cmd>AerialPrev<CR>', {buffer = bufnr})
vim.keymap.set('n', '}', '<cmd>AerialNext<CR>', {buffer = bufnr}) vim.keymap.set('n', '}', '<cmd>AerialNext<CR>', {buffer = bufnr})
end end
}) })
-- You probably also want to set a keymap to toggle aerial -- You probably also want to set a keymap to toggle aerial
vim.keymap.set('n', '<F8>', '<cmd>AerialToggle!<CR>') vim.keymap.set('n', '<F8>', '<cmd>AerialToggle!<CR>')
end, end,
} }
}) })
vim.filetype.add({ vim.filetype.add({
extension = { extension = {
vp = 'glsl', vp = 'glsl',
fp = 'glsl', fp = 'glsl',
gp = 'glsl', gp = 'glsl',
vs = 'glsl', vs = 'glsl',
fs = 'glsl', fs = 'glsl',
gs = 'glsl', gs = 'glsl',
tcs = 'glsl', tcs = 'glsl',
tes = 'glsl', tes = 'glsl',
cs = 'glsl', cs = 'glsl',
vert = 'glsl', vert = 'glsl',
frag = 'glsl', frag = 'glsl',
geom = 'glsl', geom = 'glsl',
tess = 'glsl', tess = 'glsl',
shd = 'glsl', shd = 'glsl',
gls = 'glsl', gls = 'glsl',
glsl = 'glsl', glsl = 'glsl',
rgen = 'glsl', rgen = 'glsl',
comp = 'glsl', comp = 'glsl',
rchit = 'glsl', rchit = 'glsl',
rahit = 'glsl', rahit = 'glsl',
rmiss = 'glsl', rmiss = 'glsl',
} }
}) })