Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #40 from takkii/develop
Browse files Browse the repository at this point in the history
Update.
  • Loading branch information
takkii authored Mar 3, 2024
2 parents 5ab6739 + e5c0a65 commit 31e342c
Show file tree
Hide file tree
Showing 14 changed files with 386 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# These are supported funding model platforms

github: [ takkii ]
github: [takkii]
28 changes: 28 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Python package

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# You can test your matrix by printing the current Python version
# - name: Install dependencies
# run: pip install -r requirements.txt
- name: Run Python makefile
run: chmod +x ./pake
7 changes: 7 additions & 0 deletions dev/cp_dict.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
$file = 'php_dict.txt';
$f = get_defined_functions();
sort( $f['internal'] );
$dict = implode( "\n", $f['internal'] );
file_put_contents($file, $dict);
?>
34 changes: 34 additions & 0 deletions dev/move.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

require 'open3'
require 'fileutils'

# Installer runner.
class InstallerRunner
# default encoding utf-8, change encode here.
def self.encoding_style
Encoding.default_internal = 'UTF-8'
Encoding.default_external = 'UTF-8'
end

def self.run
encoding_style
if Dir.exist?(File.expand_path('~/php_dict'))
puts 'Already have a php_dict folder...do nothing.'
else
FileUtils.mkdir_p(File.expand_path('~/php_dict'))
FileUtils.mv(['./php_dict.txt'], "#{ENV['HOME']}/dict")
puts 'Created, php dictionary folder.'
end
end
end

begin
InstallerRunner.run
rescue StandardError => e
puts e.backtrace
ensure
GC.compact
end

__END__
6 changes: 3 additions & 3 deletions uninstall.rb → dev/remove.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'open3'
require 'fileutils'

# Installer runner.
Expand All @@ -12,9 +13,8 @@ def self.encoding_style

def self.run
encoding_style
FileUtils.rm_rf(File.expand_path('~/config'))
stdout_rq, _stderr_rq, _status_rq = Open3.capture3('pip3 uninstall -y -r requirements.txt')
stdout_rq
FileUtils.rm_rf(File.expand_path('~/php_dict'))
puts 'Deleted, home directory php_dict folder.'
end
end

Expand Down
7 changes: 7 additions & 0 deletions dict/php_dict.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
$file = 'php_dict.txt';
$f = get_defined_functions();
sort( $f['internal'] );
$dict = implode( "\n", $f['internal'] );
file_put_contents($file, $dict);
?>
37 changes: 0 additions & 37 deletions install.rb

This file was deleted.

2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
msgpack-python
msgpack
pynvim
pyyaml
types-PyYAML
debugpy
111 changes: 58 additions & 53 deletions rplugin/python3/deoplete/sources/phantom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import re
import sys
import traceback
import yaml
import warnings

from deoplete.source.base import Base
Expand All @@ -18,9 +17,9 @@ class Source(Base):

def __init__(self, vim):
super().__init__(vim)
self.name: Optional[str] = 'Phantom'
self.name: Optional[str] = 'phantom'
self.filetypes = ['php']
mark_synbol: Optional[str] = '[PHP-complete]'
mark_synbol: Optional[str] = '[php_method]'
self.mark = str(mark_synbol)
php_match = [r'\.[a-zA-Z0-9_?!]*|[a-zA-Z]\w*::\w*']
slash_no_match = [r'[;/[^¥/]\*/]']
Expand All @@ -35,73 +34,79 @@ def get_complete_position(self, context):
def gather_candidates(self, context):
try:
# It doesn't support python4 yet.
py_major = sys.version_info[0]
py_minor = sys.version_info[1]

# 3.5 or higher python version is required.
if py_major == 3 and py_minor > 4:
# Settings, Config path is true/false change.
config_load: Optional[str] = '~/config/load.yml'
plug_config: Optional[
str] = '~/.neovim/plugged/config/load.yml'

# Settings, Loading File PATH.
file_load: Optional[str] = 'PHP_HOME'
plug_load: Optional[str] = 'PHP_File'

# Home Folder, Set the dictionary.
if os.path.exists(os.path.expanduser(config_load)):
with open(os.path.expanduser(config_load)) as yml:
config = yaml.safe_load(yml)

# Get Receiver/php Method Complete.
with open(os.path.expanduser(
config[file_load])) as r_method:
data = list(r_method.readlines())
data_php: Optional[list] = [s.rstrip() for s in data]
complete: Optional[list] = data_php
complete.sort(key=itemgetter(0))
return complete

# Use vim-plug, Set the dictionary.
elif os.path.exists(os.path.expanduser(plug_config)):
with open(os.path.expanduser(plug_config)) as yml:
config = yaml.safe_load(yml)

# Get Receiver/php Method Complete.
with open(os.path.expanduser(
config[plug_load])) as r_method:
data = list(r_method.readlines())
plug_php: Optional[list] = [s.rstrip() for s in data]
r_complete: Optional[list] = plug_php
r_complete.sort(key=itemgetter(0))
return r_complete
py_mj = sys.version_info[0]
py_mi = sys.version_info[1]

# 3.5 and higher, 4.x or less,python version is required.
if (py_mj == 3 and py_mi > 4) or (py_mj < 4):

# Settings, vim-plug | neovim path is true/false folder search.
neo_f: Optional[str] = '~/.neovim/plugged/phantom/dict/'
neo_t = '~/.neovim/plugged/phantom/dict/php_dict.txt'

# Settings, vim-plug | vim path is true/false folder search.
vim_f: Optional[str] = '~/.vim/plugged/phantom/dict/'
vim_t = '~/.vim/plugged/phantom/dict/php_dict.txt'

# Settings, $HOME/dict path is true/false folder search.
loc_f: Optional[str] = '~/dict/'
loc_t: Optional[str] = '~/dict/php_dict.txt'

# Use vim-plug | neovim, Set the dictionary.
if os.path.exists(os.path.expanduser(neo_f)):

# User side, normal function.
with open(os.path.expanduser(neo_t)) as r_meth:
neo_py: Optional[list] = list(r_meth.readlines())
neo_comp: Optional[list] = [s.rstrip() for s in neo_py]
neo_comp.sort(key=itemgetter(0))
return neo_comp

# Use vim-plug | vim, Set the dictionary.
elif os.path.exists(os.path.expanduser(vim_f)):

# User side, normal function.
with open(os.path.expanduser(vim_t)) as r_vim:
vim_py: Optional[list] = list(r_vim.readlines())
vim_comp: Optional[list] = [s.rstrip() for s in vim_py]
vim_comp.sort(key=itemgetter(0))
return vim_comp

# $HOME/dict, Set the dictionary to develop mode.
elif os.path.exists(os.path.expanduser(loc_f)):

# Function change destination.
with open(os.path.expanduser(loc_t)) as rb_mt:
dev_py: Optional[list] = list(rb_mt.readlines())
dev_comp: Optional[list] = [s.rstrip() for s in dev_py]
sorted(dev_comp, key=itemgetter(0))
return dev_comp

# Config Folder not found.
else:
raise ValueError("None, Please Check the Config Folder")
raise ValueError("None, Please Check the dict Folder")

# Python_VERSION: 3.5 or higher and 4.x or less.
else:
raise ValueError("Python Version Check, 3.5 or higher.")
raise ValueError("VERSION: 3.5 and higher, 4.x or less")

# TraceBack.
except Exception:
# Load/Create LogFile.
except_folder: Optional[str] = 'PHP_Except_Folder'
except_file: Optional[str] = 'PHP_Except_File'
phantom: Optional[str] = os.path.expanduser(config[except_folder])
debug_word: Optional[str] = os.path.expanduser(config[except_file])
phantom: Optional[str] = os.path.expanduser('~/phantom_log/')
db_w: Optional[str] = os.path.expanduser('~/phantom_log/debug.log')

# Load the dictionary.
if os.path.isdir(phantom):
with open(debug_word, 'a') as log_py:
with open(db_w, 'a') as log_py:
traceback.print_exc(file=log_py)

# throw except.
raise RuntimeError from None

# Phantom Foler not found.
# phantom Foler not found.
else:
raise ValueError("None, Please Check the Phantom Folder.")
raise ValueError("None, Please Check the phantom Folder.")

# Custom Exception.
except ValueError as ext:
Expand Down
8 changes: 4 additions & 4 deletions log_folder.rb → tools/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
require 'open3'
require 'fileutils'

# Installer runner.
class InstallerRunner
# Create runner.
class CreateRunner
# default encoding utf-8, change encode here.
def self.encoding_style
Encoding.default_internal = 'UTF-8'
Expand All @@ -18,13 +18,13 @@ def self.run
else
FileUtils.mkdir('phantom_log')
FileUtils.mv("#{File.dirname(__FILE__)}/phantom_log", File.expand_path('~/'))
puts 'Created a phantom_log folder.'
puts 'Created, phantom_log folder.'
end
end
end

begin
InstallerRunner.run
CreateRunner.run
rescue StandardError => e
puts e.backtrace
ensure
Expand Down
29 changes: 29 additions & 0 deletions tools/delete.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require 'open3'
require 'fileutils'

# Delete runner.
class DeleteRunner
# default encoding utf-8, change encode here.
def self.encoding_style
Encoding.default_internal = 'UTF-8'
Encoding.default_external = 'UTF-8'
end

def self.run
encoding_style
FileUtils.rm_rf(File.expand_path('~/phantom_log'))
puts 'Deleted, home directory phantom_log folder.'
end
end

begin
DeleteRunner.run
rescue StandardError => e
puts e.backtrace
ensure
GC.compact
end

__END__
Loading

0 comments on commit 31e342c

Please sign in to comment.