From 1d6812e2f0d92c792dd1ce3d42ca8f7535e9b1bd Mon Sep 17 00:00:00 2001 From: jhe Date: Wed, 22 May 2024 16:02:16 +0200 Subject: [PATCH] some changes --- ftplugin/javascript.lua | 3 +++ ftplugin/main.js | 4 ++++ ftplugin/main.py | 4 ++++ ftplugin/python.lua | 3 +++ init.lua | 36 ++++++++++++++++++++++++++++++++---- 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 ftplugin/javascript.lua create mode 100644 ftplugin/main.js create mode 100644 ftplugin/main.py create mode 100644 ftplugin/python.lua diff --git a/ftplugin/javascript.lua b/ftplugin/javascript.lua new file mode 100644 index 00000000..647ddf2b --- /dev/null +++ b/ftplugin/javascript.lua @@ -0,0 +1,3 @@ +vim.o.tabstop = 4 +vim.o.shiftwidth = 4 +vim.o.expandtab = true diff --git a/ftplugin/main.js b/ftplugin/main.js new file mode 100644 index 00000000..8e346b43 --- /dev/null +++ b/ftplugin/main.js @@ -0,0 +1,4 @@ + +if (true) { + console.log("Hello world"); +} diff --git a/ftplugin/main.py b/ftplugin/main.py new file mode 100644 index 00000000..c3464acc --- /dev/null +++ b/ftplugin/main.py @@ -0,0 +1,4 @@ + + +if True: + print("Hello world") diff --git a/ftplugin/python.lua b/ftplugin/python.lua new file mode 100644 index 00000000..17158831 --- /dev/null +++ b/ftplugin/python.lua @@ -0,0 +1,3 @@ +vim.o.tabstop = 2 +vim.o.shiftwidth = 2 +vim.o.expandtab = true diff --git a/init.lua b/init.lua index 88658ef3..918557ee 100644 --- a/init.lua +++ b/init.lua @@ -99,10 +99,10 @@ vim.g.have_nerd_font = false -- For more options, you can see `:help option-list` -- Make line numbers default -vim.opt.number = true +-- vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -193,6 +193,34 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the upper win -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` +-- Restore cursor position +vim.api.nvim_create_autocmd({ 'BufReadPost' }, { + pattern = { '*' }, + callback = function() + vim.api.nvim_exec('silent! normal! g`"zv', false) + end, +}) + +-- Function to set tab width +--[[ +local set_tab_width = function(ft, width) + vim.api.nvim_create_autocmd('FileType', { + pattern = ft, + callback = function() + vim.bo.shiftwidth = width + vim.bo.tabstop = width + --vim.bo.expandtab = true + end, + }) +end +]] +-- + +-- Set tabwidth for file types +--set_tab_width('python', 4) +--set_tab_width('c', 4) +--set_tab_width('c++', 2) + -- Highlight when yanking (copying) text -- Try it with `yap` in normal mode -- See `:help vim.highlight.on_yank()` @@ -226,7 +254,7 @@ vim.opt.rtp:prepend(lazypath) -- NOTE: Here is where you install your plugins. require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). - 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically + --'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following @@ -784,7 +812,7 @@ require('lazy').setup({ -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + vim.cmd.colorscheme 'desert' -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none'