diff --git a/Saved/completions.lua b/Saved/completions.lua new file mode 100644 index 00000000..c9307360 --- /dev/null +++ b/Saved/completions.lua @@ -0,0 +1,42 @@ +return { + { + 'saghen/blink.cmp', + -- optional: provides snippets for the snippet source + dependencies = { 'rafamadriz/friendly-snippets' }, + + -- use a release tag to download pre-built binaries + version = '1.*', + opts = { + -- C-space: Open menu or open docs if already open + -- C-n/C-p or Up/Down: Select next/previous item + -- C-e: Hide menu + -- C-k: Toggle signature help (if signature.enabled = true) + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + keymap = { preset = 'default' }, + + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = 'mono' + }, + + -- (Default) Only show the documentation popup when manually triggered + completion = { documentation = { auto_show = false } }, + + -- Default list of enabled providers defined so that you can extend it + -- elsewhere in your config, without redefining it, due to `opts_extend` + sources = { + default = { 'lsp', 'path', 'snippets', 'buffer' }, + }, + + -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance + -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, + -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` + -- + -- See the fuzzy documentation for more information + fuzzy = { implementation = "prefer_rust_with_warning" } + }, + opts_extend = { "sources.default" } + } +} diff --git a/Saved/lsp/init.lua b/Saved/lsp/init.lua index d183b43e..0cc7120d 100644 --- a/Saved/lsp/init.lua +++ b/Saved/lsp/init.lua @@ -4,6 +4,6 @@ if not status_ok then end require "user.lsp.mason" --- require("user.lsp.handlers").setup() +require("user.lsp.handlers").setup() require "user.lsp.null-ls" diff --git a/Saved/treesitter.lua b/Saved/treesitter.lua deleted file mode 100644 index adffb3f6..00000000 --- a/Saved/treesitter.lua +++ /dev/null @@ -1,23 +0,0 @@ -local status_ok, configs = pcall(require, "nvim-treesitter.configs") -if not status_ok then - return -end - -configs.setup { - ensure_installed = "all", -- one of "all", "maintained" (parsers with maintainers), or a list of languages - sync_install = false, -- install languages synchronously (only applied to `ensure_installed`) - ignore_install = { "" }, -- List of parsers to ignore installing - autopairs = { - enable = true, - }, - highlight = { - enable = true, -- false will disable the whole extension - disable = { "" }, -- list of language that will be disabled - additional_vim_regex_highlighting = true, - }, - indent = { enable = true, disable = { "yaml" } }, - context_commentstring = { - enable = true, - enable_autocmd = false, - }, -} diff --git a/init.lua b/init.lua index 1960a058..70948602 100644 --- a/init.lua +++ b/init.lua @@ -1,23 +1,22 @@ vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 -vim.g.mapleader = " " -vim.g.maplocalleader = " " +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release + vim.fn.system { + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', -- latest stable release lazypath, - }) + } end vim.opt.rtp:prepend(lazypath) - -require("lazy").setup("plugins", { +require('lazy').setup('plugins', { change_detection = { notify = false, }, @@ -26,16 +25,8 @@ require("lazy").setup("plugins", { require 'user.options' require 'user.keymaps' require 'user.colorscheme' +require 'user.autocmds' -- require 'user.cmp' -- require 'user.lsp' -- require 'user.treesitter' -- require 'user.autopairs' --- require 'user.nvim-tree' --- require 'user.bufferline' -vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight when yanking (copying) text', - group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), - callback = function() - vim.highlight.on_yank() - end, -}) diff --git a/kickstart/plugins/autopairs.lua b/kickstart/plugins/autopairs.lua deleted file mode 100644 index 87a7e5ff..00000000 --- a/kickstart/plugins/autopairs.lua +++ /dev/null @@ -1,16 +0,0 @@ --- autopairs --- https://github.com/windwp/nvim-autopairs - -return { - 'windwp/nvim-autopairs', - event = 'InsertEnter', - -- Optional dependency - dependencies = { 'hrsh7th/nvim-cmp' }, - config = function() - require('nvim-autopairs').setup {} - -- If you want to automatically add `(` after selecting a function or method - local cmp_autopairs = require 'nvim-autopairs.completion.cmp' - local cmp = require 'cmp' - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) - end, -} diff --git a/learn/learning.lua b/learn/learning.lua new file mode 100644 index 00000000..91e502a1 --- /dev/null +++ b/learn/learning.lua @@ -0,0 +1,2 @@ +local names = { "Norsh", "Dan", "Bisc", "Ella"} +return names diff --git a/learn/main.lua b/learn/main.lua new file mode 100644 index 00000000..ccd410ab --- /dev/null +++ b/learn/main.lua @@ -0,0 +1,5 @@ +local fam = require('learn.learning') +print(fam[1]) +-- for i, v in ipairs(fam) do +-- print(i, v) +-- end diff --git a/lua/plugins.lua b/lua/plugins.lua index 62d53c51..28c1b624 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,4 +1,5 @@ return { + {'folke/tokyonight.nvim'}, { "nvim-lua/popup.nvim" }, -- An implementation of the Popup API from vim in Neovim { "nvim-lua/plenary.nvim" }, -- Useful lua functions used ny lots of plugins { "windwp/nvim-autopairs" }, -- Autopairs @@ -7,15 +8,15 @@ return { -- Colorschemes -- "lunarvim/colorschemes" -- A bunch of colorschemes you can try out { "lunarvim/darkplus.nvim" }, - { "akinsho/bufferline.nvim" }, { "moll/vim-bbye" }, -- cmp plugins - { "hrsh7th/nvim-cmp" }, -- The completion plugin - { "hrsh7th/cmp-buffer" }, -- buffer completions - { "hrsh7th/cmp-path" }, -- path completions - { "hrsh7th/cmp-cmdline" }, -- cmdline completions - { "saadparwaiz1/cmp_luasnip" }, -- snippet completions - { "hrsh7th/cmp-nvim-lsp" }, + -- { "hrsh7th/nvim-cmp" }, -- The completion plugin + -- { "hrsh7th/cmp-buffer" }, -- buffer completions + -- { "hrsh7th/cmp-path" }, -- path completions + -- { "hrsh7th/cmp-nvim-lua" }, + -- { "hrsh7th/cmp-cmdline" }, -- cmdline completions + -- { "saadparwaiz1/cmp_luasnip" }, -- snippet completions + -- { "hrsh7th/cmp-nvim-lsp" }, -- snippets { "L3MON4D3/LuaSnip" }, --snippet engine diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua new file mode 100644 index 00000000..683fef2e --- /dev/null +++ b/lua/plugins/autopairs.lua @@ -0,0 +1,39 @@ +return { + "windwp/nvim-autopairs", + event = "InsertEnter", -- Load when entering insert mode + config = function() + local autopairs = require("nvim-autopairs") + + autopairs.setup({ + disable_filetype = { "TelescopePrompt", "vim" }, + check_ts = true, -- Use Treesitter to check for pairs + ts_config = { + lua = { "string" }, -- don't add pairs in lua string nodes + javascript = { "template_string" }, + java = false, -- disable treesitter check for Java + }, + fast_wrap = { + map = "", -- Alt+e to trigger fast wrap + chars = { "{", "[", "(", '"', "'" }, + pattern = [=[[%'%"%>%]%)%}%,]]=], + end_key = "$", + before_key = "h", + after_key = "l", + cursor_pos_before = true, + keys = "qwertyuiopzxcvbnmasdfghjkl", + manual_position = true, + highlight = "Search", + highlight_grey = "Comment" + }, + enable_check_bracket_line = true, -- Don't add a pair if the closing bracket is already on the same line + ignored_next_char = "[%w%.]", -- Will ignore alphanumeric and `.` after the pair + }) + + -- Optional: Integration with nvim-cmp for auto completion pairing + local cmp_status_ok, cmp = pcall(require, "cmp") + if cmp_status_ok then + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end + end, +} diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua index c5aaeb3e..2c05299c 100644 --- a/lua/plugins/dashboard.lua +++ b/lua/plugins/dashboard.lua @@ -1,7 +1,5 @@ return { "folke/snacks.nvim", - priority = 9999, - lazy = false, opts = { notifier = { enabled = true }, dashboard = { @@ -42,3 +40,4 @@ return { }, }, } + diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua new file mode 100644 index 00000000..1473d15f --- /dev/null +++ b/lua/plugins/lspconfig.lua @@ -0,0 +1,24 @@ +-- ~/.config/nvim/lua/plugins/lspconfig.lua +return { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile", "BufWritePre" }, + config = function() + local lspconfig = require("lspconfig") + local capabilities = require("cmp_nvim_lsp").default_capabilities() + + -- Example: Python + lspconfig.pyright.setup({ + capabilities = capabilities + }) + + -- Example: Lua + lspconfig.lua_ls.setup({ + capabilities = capabilities, + settings = { + Lua = { + diagnostics = { globals = { "vim" } }, + }, + }, + }) + end, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index e84f6e1a..5b273eb0 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -9,5 +9,16 @@ return { section_separators = "", component_separators = "", }, + sections = { + lualine_c = { + { + 'filename', + path=1 + }, + }, + lualine_x = {}, + lualine_y = {}, + lualine_z = {}, + }, }, } diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua new file mode 100644 index 00000000..b72654e5 --- /dev/null +++ b/lua/plugins/nvim-cmp.lua @@ -0,0 +1,68 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + -- Completion sources + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "saadparwaiz1/cmp_luasnip", + + -- Snippet engine + "L3MON4D3/LuaSnip", + + -- Optional: VSCode-style icons + "onsails/lspkind.nvim", + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + local lspkind = require("lspkind") + + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.complete(), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + { name = "buffer" }, + }), + formatting = { + format = lspkind.cmp_format({ + mode = "symbol_text", -- "text", "symbol", or "symbol_text" + maxwidth = 50, + ellipsis_char = "...", + }), + }, + }) + + -- Cmdline completion (optional) + cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" } + } + }) + + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" } + }, { + { name = "cmdline" } + }) + }) + end, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 00000000..f1ffbb42 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,50 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", -- ensures parsers stay updated + event = { "BufReadPost", "BufNewFile" }, + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = { "python", "javascript", "go" }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + indent = { + enable = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = "", + node_decremental = "", + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + move = { + enable = true, + set_jumps = true, + goto_next_start = { + ["]m"] = "@function.outer", + ["]]"] = "@class.outer", + }, + goto_previous_start = { + ["[m"] = "@function.outer", + ["[["] = "@class.outer", + }, + }, + }, + }) + end, +} diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua new file mode 100644 index 00000000..9fadb977 --- /dev/null +++ b/lua/plugins/which-key.lua @@ -0,0 +1,18 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, +} diff --git a/lua/user/autocmds.lua b/lua/user/autocmds.lua index 63331da8..a9a4d7ba 100644 --- a/lua/user/autocmds.lua +++ b/lua/user/autocmds.lua @@ -1,9 +1,3 @@ --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` --- vim.api.nvim_create_autocmd('TextYankPost', { desc = 'Highlight when yanking (copying) text', group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua index 315186d6..d90e5a53 100644 --- a/lua/user/keymaps.lua +++ b/lua/user/keymaps.lua @@ -57,7 +57,6 @@ keymap('v', '', ':m .-2==', opts) -- paste over currently selected text without yanking it keymap('v', 'p', '"_dp', opts) keymap('v', 'P', '"_dP', opts) - -- Visual Block -- -- Move text up and down keymap('x', 'J', ":move '>+1gv-gv", opts) @@ -131,3 +130,6 @@ vim.keymap.set("n", "", "ggVG", opts) vim.keymap.set("n", "YY", "va{Vy", opts) vim.keymap.set("n", "r", ":w:!python3 %", { noremap = true, silent = true }) +vim.keymap.set("n", "x", ":source %", opts) +vim.keymap.set("n", "x", ":.lua", opts) +vim.keymap.set("v", "x", ":lua", opts) diff --git a/lua/user/options.lua b/lua/user/options.lua index f3ccd40a..cb579695 100644 --- a/lua/user/options.lua +++ b/lua/user/options.lua @@ -16,7 +16,7 @@ local options = { splitbelow = true, -- force all horizontal splits to go below current window splitright = true, -- force all vertical splits to go to the right of current window swapfile = false, -- creates a swapfile - termguicolors = true, -- set term gui colors (most terminals support this) + termguicolors = true, -- set term gui colors (most terminals support this) timeoutlen = 1000, -- time to wait for a mapped sequence to complete (in milliseconds) undofile = true, -- enable persistent undo updatetime = 300, -- faster completion (4000ms default) @@ -35,12 +35,12 @@ local options = { guifont = 'monospace:h17', -- the font used in graphical neovim applications } -vim.opt.shortmess:append 'c' +-- vim.opt.shortmess:append 'c' for k, v in pairs(options) do vim.opt[k] = v end -vim.cmd 'set whichwrap+=<,>,[,],h,l' -vim.cmd [[set iskeyword+=-]] -vim.cmd [[set formatoptions-=cro]] -- TODO: this doesn't seem to work +-- vim.cmd 'set whichwrap+=<,>,[,],h,l' +-- vim.cmd [[set iskeyword+=-]] +-- vim.cmd [[set formatoptions-=cro]] -- TODO: this doesn't seem to work diff --git a/tester.py b/tester.py index 8f178cda..7c30a2c7 100644 --- a/tester.py +++ b/tester.py @@ -1,4 +1,15 @@ items = [1, 2, 3] print([x**2 for x in items]) -print(items*2) +print([x**3 for x in items]) + +for i in items: + print(i) + +def myfunc(): + print("this is my func") + +def myfunc2(): + pass + +myfunc()